當前位置: 首頁>>代碼示例>>C#>>正文


C# Tests.UnitTestDbConnection類代碼示例

本文整理匯總了C#中zvs.Processor.Tests.UnitTestDbConnection的典型用法代碼示例。如果您正苦於以下問題:C# UnitTestDbConnection類的具體用法?C# UnitTestDbConnection怎麽用?C# UnitTestDbConnection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UnitTestDbConnection類屬於zvs.Processor.Tests命名空間,在下文中一共展示了UnitTestDbConnection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的zvs.Processor.Tests.UnitTestDbConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。