private void LogThisLoginInDatabase(string email) { TodoPagosContext databaseContext = new TodoPagosContext(); IUnitOfWork unitOfWork = new UnitOfWork(databaseContext); ILogStrategy log = new LogDatabaseConcreteStrategy(unitOfWork); LogEntry entry = new LogEntry(ActionType.LOGIN, email); log.SaveEntry(entry); unitOfWork.Dispose(); }
public void BeAbleToSaveALogEntry() { var mockUnitOfWork = new Mock <IUnitOfWork>(); string userEmail = "*****@*****.**"; LogDatabaseConcreteStrategy newLog = new LogDatabaseConcreteStrategy(mockUnitOfWork.Object); LogEntry newLogEntry = new LogEntry(ActionType.LOGIN, userEmail); ICollection <LogEntry> allEntries = new List <LogEntry>() { newLogEntry }; mockUnitOfWork.Setup(u => u.EntriesRepository.Insert(It.IsAny <LogEntry>())); mockUnitOfWork.Setup(u => u.Save()); mockUnitOfWork.Setup(u => u.EntriesRepository.Get(null, null, "")).Returns(allEntries); newLog.SaveEntry(newLogEntry); CollectionAssert.AreEqual((ICollection)allEntries, (ICollection)newLog.GetEntries(DateTime.MinValue, DateTime.MaxValue)); mockUnitOfWork.VerifyAll(); }