Beispiel #1
0
        public async void Get_Gateway_Returns_Element_If_Exists()
        {
            builder.UseInMemoryDatabase("Get_Gateway_Returns_Element_If_Exists");
            var options = builder.Options;
            var gateway = new Domain.Gateway()
            {
                Id           = 1,
                SerialNumber = "G1",
                IPV4Address  = "12.12.1.2",
                Name         = "G1"
            };

            using (var context = new TestDbContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                context.Add(gateway);
                context.SaveChanges();
            }

            Domain.Gateway existingGateway    = null;
            Domain.Gateway nonExistingGateway = null;

            using (var context = new TestDbContext(options))
            {
                var repository = new GatewayRepository(context);
                existingGateway = await repository.Get(1);

                nonExistingGateway = await repository.Get(2);
            }

            Assert.True(existingGateway != null && nonExistingGateway == null);
            Assert.True(existingGateway.Id == gateway.Id &&
                        existingGateway.IPV4Address == gateway.IPV4Address &&
                        existingGateway.Name == gateway.Name &&
                        existingGateway.SerialNumber == gateway.SerialNumber);
        }