コード例 #1
0
        public void Should_Create_Forwarding_Server_Entry()
        {
            new ModelMappings().Create();
            var forwardingServer = new ForwardingServer()
            {
                Name = "test",
                IpV4 = "192.168.1.1",
            };

            IUnitOfWorkProvider unitOfWorkProvider = new NPocoUnitOfWorkProvider();
            using (var uow = unitOfWorkProvider.GetUnitOfWork())
            {
                IForwardingServersRepository repository = new ForwardingServersRepository();
                repository.DeleteAllEntries(uow);

                var id = repository.AddFowardingServer(uow, forwardingServer);

                uow.Commit();

                id.Should().BeGreaterThan(0, "because a valid ID should have been returned when the entry was created.");
                forwardingServer.Id.Should().Be(id, "because a valid ID should have been returned when the entry was created.");
            }
        }
コード例 #2
0
        public void Should_Update_Forwarding_Server_Entry()
        {
            new ModelMappings().Create();
            var forwardingServer = new ForwardingServer()
            {
                Name = "testing",
                IpV4 = "192.168.1.1",
            };

            IUnitOfWorkProvider unitOfWorkProvider = new NPocoUnitOfWorkProvider();
            using (var uow = unitOfWorkProvider.GetUnitOfWork())
            {
                IForwardingServersRepository repository = new ForwardingServersRepository();
                repository.DeleteAllEntries(uow);

                var id = repository.AddFowardingServer(uow, forwardingServer);

                forwardingServer.Name = "test2";
                repository.UpdateForwardingServer(uow, forwardingServer);
                var updatedEntry = repository.GetForwardingServer(uow, forwardingServer.Id);
                updatedEntry.Name.Should().Be(forwardingServer.Name);

            }
        }