public void RemoveSession_SessionIdProvided_SessionShouldBeRemovedFromMemoryAndFile() { var sessionId = "SessionId"; var session = new Session { Id = sessionId }; inMemoryStorage.Clear(); inMemoryStorage.Add(session); dataProvider.AddSession(session); subject.RemoveSession(sessionId); var resultFromMemory = inMemoryStorage.GetSessionSave(sessionId); resultFromMemory.IsSuccessful.Should().BeFalse(); var resultFromFile = dataProvider.GetSessionSave(sessionId); resultFromFile.IsSuccessful.Should().BeFalse(); }
public FuncResult <Session> GetSessionSave(string sessionId) { if (settings.IsEnabledFileCache && inMemoryStorage.DoesSessionExist(sessionId)) { return(inMemoryStorage.GetSessionSave(sessionId)); } var resultFromFile = dataProvider.GetSessionSave(sessionId); if (resultFromFile.IsSuccessful) { inMemoryStorage.Add(resultFromFile.Value); return(resultFromFile); } if (settings.IsSessionAutoCreate) { var session = inMemoryStorage.CreateSession(sessionId); return(session.AsFuncResult()); } return(FuncResult.Failed <Session>()); }