public void RemainingTimeTest() { var brainstormingDalMock = BrainstormingDalMock(1); brainstormingDalMock.SetupSequence(req => req.GetRemainingTime(It.IsAny <string>(), It.IsAny <string>())) .Returns(TimeSpan.FromSeconds(10)) .Returns(TimeSpan.FromSeconds(5)); var teamDalMock = TeamDalMock(); var dalMock = new Mock <IDalService>(); dalMock.Setup(serv => serv.BrainstormingDalService).Returns(brainstormingDalMock.Object); dalMock.Setup(serv => serv.TeamDalService).Returns(teamDalMock.Object); var brainstormingService = new BrainstormingService( _logMock, dalMock.Object, BrainstormingModelFactory.CreateContext(1), new BrainstormingModel()); brainstormingService.StartBusinessService(); Thread.Sleep(1100); var remainingTime = brainstormingService.RemainingTime; Thread.Sleep(1100); Assert.IsTrue(remainingTime > brainstormingService.RemainingTime); }
public void EndedStateTest() { var brainstormingDalMock = BrainstormingDalMock(-1); var teamDalMock = TeamDalMock(); var dalMock = new Mock <IDalService>(); dalMock.Setup(serv => serv.BrainstormingDalService).Returns(brainstormingDalMock.Object); dalMock.Setup(serv => serv.TeamDalService).Returns(teamDalMock.Object); var brainstormingService = new BrainstormingService( _logMock, dalMock.Object, BrainstormingModelFactory.CreateContext(-1), new BrainstormingModel()); brainstormingService.StartBusinessService(); Assert.IsTrue(brainstormingService.IsEnded); Assert.IsFalse(brainstormingService.IsWaiting); Assert.IsFalse(brainstormingService.IsRunning); }
public void StartRoundTest() { var brainstormingDalMock = BrainstormingDalMock(1); var teamDalMock = TeamDalMock(); var dalMock = new Mock <IDalService>(); dalMock.Setup(serv => serv.BrainstormingDalService).Returns(brainstormingDalMock.Object); dalMock.Setup(serv => serv.TeamDalService).Returns(teamDalMock.Object); var brainstormingService = new BrainstormingService( _logMock, dalMock.Object, BrainstormingModelFactory.CreateContext(0), new BrainstormingModel()); brainstormingService.StartBusinessService(); Assert.IsTrue(brainstormingService.IsWaiting); Thread.Sleep(4500); Assert.IsTrue(brainstormingService.IsRunning); }
private BrainstormingService BasicServiceSetup() { var brainstormingDalMock = new Mock <IBrainstormingDalService>(); brainstormingDalMock.SetupSequence(request => request.GetFinding(It.IsAny <string>())) .Returns(BrainstormingModelFactory.CreateFinding(1)) .Returns(BrainstormingModelFactory.CreateFinding(-1)); brainstormingDalMock.Setup(req => req.UpdateSheet(It.IsAny <string>(), It.IsAny <BrainSheet>())) .Returns(true); var participantDalMock = new Mock <IParticipantDalService>(); var teamDalMock = TeamDalMock(); var model = new BrainstormingModel() { BrainSheets = new ObservableCollection <BrainSheet>() }; var context = BrainstormingModelFactory.CreateContext(1); context.CurrentFinding.BrainSheets = new List <BrainSheet>() { new BrainSheet() }; var dalMock = new Mock <IDalService>(); dalMock.Setup(s => s.BrainstormingDalService).Returns(brainstormingDalMock.Object); dalMock.Setup(s => s.ParticipantDalService).Returns(participantDalMock.Object); dalMock.Setup(s => s.TeamDalService).Returns(teamDalMock.Object); var brainstormingService = new BrainstormingService( _logMock, dalMock.Object, context, model ); return(brainstormingService); }