本文整理汇总了C#中zvs.Processor.Tests.UnitTestDbConnection类的典型用法代码示例。如果您正苦于以下问题:C# UnitTestDbConnection类的具体用法?C# UnitTestDbConnection怎么用?C# UnitTestDbConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitTestDbConnection类属于zvs.Processor.Tests命名空间,在下文中一共展示了UnitTestDbConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RegisterAsyncNewTest
public async Task RegisterAsyncNewTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var dsb = new DeviceSettingBuilder(dbConnection);
var deviceSetting = new DeviceSetting
{
Name = "Unit Test Device Setting",
UniqueIdentifier = "DEVICE_SETTING1"
};
//act
var result = await dsb.RegisterAsync(deviceSetting, CancellationToken.None);
DeviceSetting setting;
using (var context = new ZvsContext(dbConnection))
{
setting =
await
context.DeviceSettings.FirstOrDefaultAsync(
o => o.UniqueIdentifier == deviceSetting.UniqueIdentifier);
}
//assert
Console.WriteLine(result.Message);
Assert.IsFalse(result.HasError, result.Message);
Assert.IsNotNull(setting, "Expected new device setting saved to DB");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:31,代码来源:DeviceSettingBuilderTests.cs
示例2: RegisterAsyncNewDeviceValueTest
public async Task RegisterAsyncNewDeviceValueTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var dvb = new DeviceValueBuilder( dbConnection);
var device = UnitTesting.CreateFakeDevice();
using (var context = new ZvsContext(dbConnection))
{
context.Devices.Add(device);
await context.SaveChangesAsync();
var deviceValue = new DeviceValue
{
Description = "Testing Value Description Here",
Name = "Test Value",
ValueType = DataType.BOOL,
Value = true.ToString(),
DeviceId = device.Id
};
//act
var result = await dvb.RegisterAsync(deviceValue, device, CancellationToken.None);
var dv = await context.DeviceValues.FirstOrDefaultAsync(o => o.Name == deviceValue.Name);
//assert
Assert.IsFalse(result.HasError, result.Message);
Assert.IsNotNull(dv, "Registered device value count not be found in database.");
Console.WriteLine(result.Message);
}
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:34,代码来源:DeviceValueBuilderTests.cs
示例3: LoadAdaptersNameTooLongAsyncTest
public async Task LoadAdaptersNameTooLongAsyncTest()
{
//Arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var logEntries = new List<LogEntry>();
var log = new StubIFeedback<LogEntry>
{
ReportAsyncT0CancellationToken = (e, c) =>
{
Console.WriteLine(e.ToString());
logEntries.Add(e);
return Task.FromResult(0);
}
};
var longNameAdapter = new StubZvsAdapter
{
AdapterGuidGet = () => Guid.Parse("a0f912a6-b8bb-406a-360f-1eb13f50aae4"),
NameGet = () => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque magna diam, pellentesque et orci eget, pellentesque iaculis odio. Ut ultrices est sapien, ac pellentesque odio malesuada a. Etiam in neque ullamcorper massa gravida ullamcorper vel a posuere.",
DescriptionGet = () => "",
OnSettingsCreatingAdapterSettingBuilder = s => Task.FromResult(0),
OnDeviceTypesCreatingDeviceTypeBuilder = s => Task.FromResult(0)
};
var adapterManager = new AdapterManager(new List<ZvsAdapter>() { longNameAdapter }, dbConnection, log);
//act
await adapterManager.StartAsync(CancellationToken.None);
//assert
Assert.IsTrue(logEntries.Count(o => o.Level == LogEntryLevel.Error) == 1, "Expected 1 error");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:33,代码来源:AdapterManagerTests.cs
示例4: RegisterAsyncNewDeviceTypeTest
public async Task RegisterAsyncNewDeviceTypeTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var dtb = new DeviceTypeBuilder( dbConnection);
var adapter = UnitTesting.CreateFakeAdapter();
using (var context = new ZvsContext(dbConnection))
{
context.Adapters.Add(adapter);
await context.SaveChangesAsync();
}
var dt = new DeviceType
{
AdapterId = adapter.Id,
UniqueIdentifier = "UNIT_TEST_DEVICE_TYPE1",
Name = "Unit Test Device Type"
};
//act
var result = await dtb.RegisterAsync(adapter.AdapterGuid, dt, CancellationToken.None);
//assert
Console.WriteLine(result.Message);
Assert.IsFalse(result.HasError);
Assert.IsTrue(dt.Id > 0, "Expected device type to have a database generated Id");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:29,代码来源:DeviceTypeBuilderTests.cs
示例5: RegisterAsyncNewTest
public async Task RegisterAsyncNewTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var bcb = new BuiltinCommandBuilder(dbConnection);
var builtinCommand = new BuiltinCommand
{
Name = "Unit Test Builtin Command",
UniqueIdentifier = "BUILTIN_COMMAND1"
};
//act
var result = await bcb.RegisterAsync(builtinCommand, CancellationToken.None);
BuiltinCommand setting;
using (var context = new ZvsContext(dbConnection))
{
setting =
await
context.BuiltinCommands.FirstOrDefaultAsync(
o => o.UniqueIdentifier == builtinCommand.UniqueIdentifier);
}
//assert
Console.WriteLine(result.Message);
Assert.IsFalse(result.HasError, result.Message);
Assert.IsNotNull(setting, "Expected new builtin command setting saved to DB");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:31,代码来源:BuiltinCommandBuilderTests.cs
示例6: ConstructorNullArg1Test
public void ConstructorNullArg1Test()
{
//arrange
var dbConnection = new UnitTestDbConnection();
//act
new DeviceValueBuilder(null);
//assert - throws exception
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:8,代码来源:DeviceValueBuilderTests.cs
示例7: ConstructorTest
public void ConstructorTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
//act
var bcb = new BuiltinCommandBuilder(dbConnection);
//assert
Assert.IsNotNull(bcb);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:9,代码来源:BuiltinCommandBuilderTests.cs
示例8: ConstructorTest
public void ConstructorTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
//act
var dvb = new DeviceValueBuilder(dbConnection);
//assert
Assert.IsNotNull(dvb);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:9,代码来源:DeviceValueBuilderTests.cs
示例9: ConstructorTest
public void ConstructorTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
//act
var ssb = new SceneSettingBuilder(dbConnection);
//assert
Assert.IsNotNull(ssb);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:9,代码来源:SceneSettingBuilderTests.cs
示例10: ConstructorNullArg1Test
public void ConstructorNullArg1Test()
{
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
//arrange
//act
new TriggerRunner(null, new StubICommandProcessor(), new UnitTestDbConnection());
//assert - throws exception
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:9,代码来源:TriggerRunnerTests.cs
示例11: RegisterAsyncNullDeviceValueTest
public async Task RegisterAsyncNullDeviceValueTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
var dvb = new DeviceValueBuilder( dbConnection);
//act
var result = await dvb.RegisterAsync(null, new Device(), CancellationToken.None);
//assert
Assert.IsTrue(result.HasError);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:12,代码来源:DeviceValueBuilderTests.cs
示例12: RegisterAsyncNullBuiltinCommandTest
public async Task RegisterAsyncNullBuiltinCommandTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
var bcb = new BuiltinCommandBuilder(dbConnection);
//act
var result = await bcb.RegisterAsync(null, CancellationToken.None);
//assert
Console.WriteLine(result.Message);
Assert.IsTrue(result.HasError, result.Message);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:13,代码来源:BuiltinCommandBuilderTests.cs
示例13: RegisterAsyncNullDeviceTest
public async Task RegisterAsyncNullDeviceTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
var dsb = new DeviceSettingBuilder(dbConnection);
//act
var result = await dsb.RegisterAsync(null, CancellationToken.None);
//assert
Console.WriteLine(result.Message);
Assert.IsTrue(result.HasError, result.Message);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:13,代码来源:DeviceSettingBuilderTests.cs
示例14: RegisterAsyncNullDeviceValueTest
public async Task RegisterAsyncNullDeviceValueTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
var dvb = new DeviceCommandBuilder( dbConnection);
//act
var result = await dvb.RegisterAsync(1, null, CancellationToken.None);
//assert
Assert.IsTrue(result.HasError);
Console.WriteLine(result.Message);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:13,代码来源:DeviceCommandBuilderTests.cs
示例15: ConstructorNullArg3Test
public void ConstructorNullArg3Test()
{
//arrange
var fb = new StubIFeedback<LogEntry>();
var am = new StubIAdapterManager();
var connection = new UnitTestDbConnection();
var tr = new TriggerRunner(fb, new StubICommandProcessor(), connection);
var st = new StubScheduledTaskRunner(fb, new StubICommandProcessor(), connection, new StubITimeProvider());
//act
new ZvsEngine(fb, am, null, connection, tr, st);
//assert - throws exception
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:13,代码来源:ZvsEngineTests.cs
示例16: RegisterAsyncInvalidAdapterTest
public async Task RegisterAsyncInvalidAdapterTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var dtb = new DeviceTypeBuilder( dbConnection);
//act
var result = await dtb.RegisterAsync(new Guid(), new DeviceType(), CancellationToken.None);
//assert
Assert.IsTrue(result.HasError);
Console.WriteLine(result.Message);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:15,代码来源:DeviceTypeBuilderTests.cs
示例17: RegisterPluginSettingNullPluginTest
public async Task RegisterPluginSettingNullPluginTest()
{
//Arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var pluginBuilder = new PluginSettingBuilder( dbConnection, CancellationToken.None);
var plugin = new StubUnitTestPlugin();
//act
var result = await pluginBuilder.Plugin(plugin).RegisterPluginSettingAsync(new PluginSetting(), o => o.PropertyTest);
//assert
Console.WriteLine(result.Message);
Assert.IsTrue(result.HasError);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:15,代码来源:PluginSettingBuilderTests.cs
示例18: RegisterAsyncInvalidDeviceIdTest
public async Task RegisterAsyncInvalidDeviceIdTest()
{
//arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var dvb = new DeviceCommandBuilder(dbConnection);
var deviceCommand = new DeviceCommand();
//act
var result = await dvb.RegisterAsync(3, deviceCommand, CancellationToken.None);
//assert
Assert.IsTrue(result.HasError);
Console.WriteLine(result.Message);
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:16,代码来源:DeviceCommandBuilderTests.cs
示例19: RegisterPluginSettingPluginTest
public async Task RegisterPluginSettingPluginTest()
{
//Arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var pluginBuilder = new PluginSettingBuilder(dbConnection, CancellationToken.None);
var dbPlugin = UnitTesting.CreateFakePlugin();
using (var context = new ZvsContext(dbConnection))
{
context.Plugins.Add(dbPlugin);
await context.SaveChangesAsync();
}
var plugin = new StubUnitTestPlugin
{
PluginGuidGet = () => dbPlugin.PluginGuid
};
var pluginSetting = new PluginSetting
{
Name = "Plugin Setting 1",
ValueType = DataType.STRING,
Value = "Hello World"
};
//act
var result = await pluginBuilder.Plugin(plugin).RegisterPluginSettingAsync(pluginSetting, o => o.PropertyTest);
Plugin a;
using (var context = new ZvsContext(dbConnection))
{
a = await context.Plugins
.Include(o=> o.Settings)
.FirstOrDefaultAsync(o => o.PluginGuid == dbPlugin.PluginGuid);
}
//assert
Console.WriteLine(result.Message);
Assert.IsFalse(result.HasError);
Assert.IsTrue(a.Settings.Count == 1, "Expected 1 plugin setting");
Assert.IsTrue(a.Settings[0].Name == pluginSetting.Name, "Plugin setting name mismatch");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:41,代码来源:PluginSettingBuilderTests.cs
示例20: ExecuteDeviceCommandAsyncInvalidIdTest
public async Task ExecuteDeviceCommandAsyncInvalidIdTest()
{
//Arrange
var dbConnection = new UnitTestDbConnection();
Database.SetInitializer(new CreateFreshDbInitializer());
var adapterManager = new StubIAdapterManager();
var ranstoredCommands = new List<int>();
var log = new StubIFeedback<LogEntry>();
var cts = new CancellationTokenSource();
var commmandProcessor = new CommandProcessor(adapterManager, dbConnection, log);
//Act
var result = await commmandProcessor.ExecuteDeviceCommandAsync(new DeviceCommand(), "", "", cts.Token);
Console.WriteLine(result.Message);
//Assert
Assert.IsTrue(result.HasError);
Assert.IsTrue(ranstoredCommands.Count == 0, "Process did not run the correct amount of commands.");
Assert.IsTrue(result.Message.Contains("Cannot locate"), "Expect error message to contain 'Cannot locate'");
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:21,代码来源:CommandProcessorTests.cs
注:本文中的zvs.Processor.Tests.UnitTestDbConnection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论