public void Update_Test() { Mock <BaseStartupDemo> mockedContext = new Mock <BaseStartupDemo>(); mockedContext.Object.Configurations = LoadMockedUsers(); ConfigurationsRepository repo = new ConfigurationsRepository(mockedContext.Object, false); repo.Update(new DtoConfiguration(1, "Updated Config", "Updated Config Value")); DtoConfiguration updated = (from u in mockedContext.Object.Configurations where u.ID == 1 select u).FirstOrDefault(); Assert.AreEqual <string>("Updated Config", updated.Name); Assert.AreEqual <string>("Updated Config Value", updated.Value); }
public void Update_In_ReadOnly_Test() { Mock <BaseStartupDemo> mockedContext = new Mock <BaseStartupDemo>(); mockedContext.Object.Configurations = LoadMockedUsers(); ConfigurationsRepository repo = new ConfigurationsRepository(mockedContext.Object, true); Exception expected_ex = null; try { repo.Update(new DtoConfiguration(1, "Updated Config", "Updated Config Value")); } catch (ReadOnlyException ex) { expected_ex = ex; } Assert.IsNotNull(expected_ex); }