public void ApplyUserSettings_CanWriteIsZeroSiteOpen_ReturnsCannotWrite() { var user = Mocks.DynamicMock<IUser>(); user.Stub(x => x.IsEditor).Return(false); user.Stub(x => x.IsSuperUser).Return(false); var site = Mocks.DynamicMock<ISite>(); site.Stub(x => x.IsEmergencyClosed).Return(false); site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false); Mocks.ReplayAll(); var target = new ForumThreads { CanWrite = 0, DefaultCanWrite = 0 }; target.ApplyUserSettings(user, site); Assert.AreEqual(0, target.CanWrite); }
public void ApplyUserSettings_NullUserWithCanWriteIsOneAndDefaultIsZero_ReturnsCannotWrite() { IUser user = null; var site = Mocks.DynamicMock<ISite>(); site.Stub(x => x.IsEmergencyClosed).Return(false); site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false); Mocks.ReplayAll(); var target = new ForumThreads { CanWrite = 1, DefaultCanWrite = 0 }; target.ApplyUserSettings(user, site); Assert.AreEqual(0, target.CanWrite); }
public void ApplyUserSettings_IsEditor_ReturnsCanWrite() { var user = Mocks.DynamicMock<IUser>(); user.Stub(x => x.IsEditor).Return(true); user.Stub(x => x.IsSuperUser).Return(false); var site = Mocks.DynamicMock<ISite>(); site.Stub(x => x.IsEmergencyClosed).Return(false); site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false); Mocks.ReplayAll(); var target = new ForumThreads { Thread = new List<ThreadSummary> {ThreadSummaryTest.CreateThreadSummaryTest()} , CanWrite=0 ,DefaultCanWrite=0 }; target.ApplyUserSettings(user, site); Assert.AreEqual(1, target.CanWrite); }