public void CanDeleteContactState() { var guid = Guid.NewGuid(); var name = "To be deleted."; var inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder(); var options = inMemoryDatabaseBuilder.WithContactState(guid, name).Build("DeleteContactState", true); // Run the test against a clean instance of the context using (var context = new MainContext(options)) { inMemoryDatabaseBuilder.InitializeContext(context); var sut = new MainRepository(context); var state = context.ContactStates.Find(guid); Assert.Equal(EntityState.Unchanged, context.Entry(state).State); sut.DeleteContactState(guid); Assert.Equal(EntityState.Deleted, context.Entry(state).State); } }
public void GetContactState_Succeeds_OnlyWhenGuidMatchesExisting() { var guid = Guid.NewGuid(); var invalidGuid = Guid.NewGuid(); const string name = "Cool Contact"; var inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder(); var options = inMemoryDatabaseBuilder.WithContactState(guid, name).Build("GetContactState"); // Run the test against a clean instance of the context using (var context = new MainContext(options)) { inMemoryDatabaseBuilder.InitializeContext(context); var sut = new MainRepository(context); var state = sut.GetContactState(guid); var invalidState = sut.GetContactState(invalidGuid); Assert.Equal(name, state.Name); Assert.Null(invalidState); } }