public void LogEntryUpdatesDB() { ISessionFacade f = this.DumbAss; bool inserted = false; bool committed = false; Mock <IRepository <Log> > mLogRepo = new Mock <IRepository <Log> >(); mLogRepo.Setup(g => g.Insert(It.IsAny <Log>())).Callback(() => { inserted = true; }); Mock <DxContext> mDimension = new Mock <DxContext>(); mDimension.Setup(g => g.SaveChanges()).Callback(() => { committed = true; }); ((SessionFacade)f).Dimension = mDimension.Object; ((SessionFacade)f).LogRepo = mLogRepo.Object; f.Log(new TraceLogEntry("test", System.Diagnostics.TraceEventType.Information), new Session() { id = 1 }); Assert.True(inserted && committed); }
public void LogEntryNullSessionEx() { Assert.Throws <System.ArgumentNullException>(() => { ISessionFacade f = this.DumbAss; TraceLogEntry e = new TraceLogEntry("test message", System.Diagnostics.TraceEventType.Information); f.Log(e, null); }); }