public void CreateTestData() { IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ServerRegistrationRepository repository = CreateRepository(provider); repository.Save(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.Now) { IsActive = true }); repository.Save(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.Now)); repository.Save(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.Now)); scope.Complete(); } }
public void Cannot_Add_Duplicate_Server_Identities() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { ServerRegistrationRepository repository = CreateRepository(provider); var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now); Assert.That(() => repository.Save(server), Throws.InstanceOf <DbException>()); } }
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>()); } }
public void Can_Perform_Add_On_Repository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { ServerRegistrationRepository repository = CreateRepository(provider); // Act var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now); repository.Save(server); // Assert Assert.That(server.HasIdentity, Is.True); Assert.That(server.Id, Is.EqualTo(4)); // With 3 existing entries the Id should be 4 } }
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)); } }