public void Cannot_Update_To_Duplicate_Server_Identities()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                ServerRegistrationRepository repository = CreateRepository(provider);

                IServerRegistration server = repository.Get(1);
                server.ServerIdentity = "COMPUTER2";

                Assert.That(() => repository.Save(server), Throws.InstanceOf <DbException>());
            }
        }
示例#2
0
        public void Cannot_Update_To_Duplicate_Computer_Names()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                var server = repository.Get(1);
                server.ComputerName = "COMPUTER2";
                repository.AddOrUpdate(server);
                Assert.Throws <SqlCeException>(unitOfWork.Commit);
            }
        }
示例#3
0
        public void Can_Perform_Update_On_Repository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(2);
                server.ServerAddress = "https://umbraco.com";
                server.IsActive      = true;

                repository.AddOrUpdate(server);
                unitOfWork.Commit();

                var serverUpdated = repository.Get(2);

                // Assert
                Assert.That(serverUpdated, Is.Not.Null);
                Assert.That(serverUpdated.ServerAddress, Is.EqualTo("https://umbraco.com"));
                Assert.That(serverUpdated.IsActive, Is.EqualTo(true));
            }
        }
        public void Can_Perform_Update_On_Repository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                ServerRegistrationRepository repository = CreateRepository(provider);

                // Act
                IServerRegistration server = repository.Get(2);
                server.ServerAddress = "https://umbraco.com";
                server.IsActive      = true;

                repository.Save(server);

                IServerRegistration serverUpdated = repository.Get(2);

                // Assert
                Assert.That(serverUpdated, Is.Not.Null);
                Assert.That(serverUpdated.ServerAddress, Is.EqualTo("https://umbraco.com"));
                Assert.That(serverUpdated.IsActive, Is.EqualTo(true));
            }
        }
        public void Cannot_Update_To_Duplicate_Computer_Names()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                var server = repository.Get(1);
                server.ComputerName = "COMPUTER2";
                repository.AddOrUpdate(server);
                Assert.Throws<SqlCeException>(unitOfWork.Commit);
            }

        }
示例#6
0
        public void Can_Perform_Get_On_Repository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(1);

                // Assert
                Assert.That(server, Is.Not.Null);
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.ServerAddress, Is.EqualTo("http://localhost"));
            }
        }
        public void Can_Perform_Get_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(1);

                // Assert
                Assert.That(server, Is.Not.Null);
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.ServerAddress, Is.EqualTo("http://localhost"));    
            }

            
        }
        public void Can_Perform_Get_On_Repository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                ServerRegistrationRepository repository = CreateRepository(provider);

                // Act
                IServerRegistration server = repository.Get(1);

                // Assert
                Assert.That(server, Is.Not.Null);
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.ServerAddress, Is.EqualTo("http://localhost"));
            }
        }
示例#9
0
        public void Can_Perform_Delete_On_Repository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(3);
                Assert.IsNotNull(server);
                repository.Delete(server);
                unitOfWork.Commit();

                var exists = repository.Exists(3);

                // Assert
                Assert.That(exists, Is.False);
            }
        }
        public void Can_Perform_Delete_On_Repository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                ServerRegistrationRepository repository = CreateRepository(provider);

                // Act
                IServerRegistration server = repository.Get(3);
                Assert.IsNotNull(server);
                repository.Delete(server);

                bool exists = repository.Exists(3);

                // Assert
                Assert.That(exists, Is.False);
            }
        }
        public void Can_Perform_Delete_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(3);
                Assert.IsNotNull(server);
                repository.Delete(server);
                unitOfWork.Commit();

                var exists = repository.Exists(3);

                // Assert
                Assert.That(exists, Is.False);   
            }            
        }
        public void Can_Perform_Update_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = repository.Get(2);
                server.ServerAddress = "https://umbraco.com";
                server.IsActive = true;

                repository.AddOrUpdate(server);
                unitOfWork.Commit();

                var serverUpdated = repository.Get(2);

                // Assert
                Assert.That(serverUpdated, Is.Not.Null);
                Assert.That(serverUpdated.ServerAddress, Is.EqualTo("https://umbraco.com"));
                Assert.That(serverUpdated.IsActive, Is.EqualTo(true));   
            }            
        }