Ejemplo n.º 1
0
        public void CreateTestData()
        {
            var provider = new PetaPocoUnitOfWorkProvider();

            using (var unitOfWork = provider.GetUnitOfWork())
                using (var repository = new ServerRegistrationRepository(unitOfWork))
                {
                    repository.AddOrUpdate(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.Now)
                    {
                        IsActive = true
                    });
                    repository.AddOrUpdate(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.Now));
                    repository.AddOrUpdate(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.Now));
                    unitOfWork.Commit();
                }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        public void Cannot_Add_Duplicate_Computer_Names()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now);
                repository.AddOrUpdate(server);

                Assert.Throws <SqlCeException>(unitOfWork.Commit);
            }
        }
        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);
            }

        }
        public void Cannot_Add_Duplicate_Computer_Names()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now);
                repository.AddOrUpdate(server);

                Assert.Throws<SqlCeException>(unitOfWork.Commit);
            }

        }
Ejemplo n.º 6
0
        public void Can_Perform_Add_On_Repository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now);
                repository.AddOrUpdate(server);
                unitOfWork.Commit();

                // Assert
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.Id, Is.EqualTo(4));//With 3 existing entries the Id should be 4
            }
        }
Ejemplo n.º 7
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 CreateTestData()
        {
            var provider = new PetaPocoUnitOfWorkProvider();
            using (var unitOfWork = provider.GetUnitOfWork())
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                repository.AddOrUpdate(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.Now) { IsActive = true });
                repository.AddOrUpdate(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.Now));
                repository.AddOrUpdate(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.Now));
                unitOfWork.Commit();
            }

        }
        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_Add_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now);
                repository.AddOrUpdate(server);
                unitOfWork.Commit();

                // Assert
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.Id, Is.EqualTo(4));//With 3 existing entries the Id should be 4   
            }            
        }