public void GetAllPomodoros_TestMethod()
        {
            var testPomorodo = new Pomodoro()
            {
                Id          = Guid.NewGuid(),
                StartTime   = "TestStartTime",
                FinishTime  = "TestFinishTime",
                Description = "TestDescription"
            };

            var repositoryMock = new Mock <IPomodoroRepository>();

            repositoryMock.Setup(pr => pr.GetAllPomodoros()).ReturnsAsync(new List <Pomodoro> {
                testPomorodo
            });

            var repositoryWrapperMock = new Mock <IRepositoryWrapper>();

            repositoryWrapperMock.Setup(rw => rw.Pomodoro).Returns(repositoryMock.Object);

            var mapperMock = new Mock <IMapper>();

            var loggerMock = new Mock <ILoggerManager>();

            loggerMock.Setup(pr => pr.LogInfo("Test"));

            var pc       = new PomodoroController(repositoryWrapperMock.Object, mapperMock.Object, loggerMock.Object);
            var result   = pc.GetAllPomodoros().Result;
            var okResult = result as OkObjectResult;

            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
        }
示例#2
0
 public override void Start(PomodoroController controller)
 {
     if (controller.FocusOnText.Length > 0)
     {
         SetNextState(controller);
     }
 }
示例#3
0
        public override void Start(PomodoroController controller)
        {
            TimeSpan elapsedFullMinutes  = new TimeSpan(0, 0, MinutesInState - MinuteCountDown, 0);
            TimeSpan elapsedTime         = PauseTime.Subtract(StartTime).Subtract(PreviousState.TotalPauseTimeSpan);
            TimeSpan totalPauseTimeSpan  = DateTime.Now.Subtract(StartTime).Subtract(elapsedTime);
            double   minuteTimerTimeLeft = MilisecondsPerMinute - elapsedTime.Subtract(elapsedFullMinutes).TotalMilliseconds;

            Console.WriteLine($"{nameof(Paused)}");
            Console.WriteLine($"   elapsedFullMinutes  = {elapsedFullMinutes.TotalMilliseconds}");
            Console.WriteLine($"   elapsedTime         = {elapsedTime.TotalMilliseconds}");
            Console.WriteLine($"   totalPauseTimeSpan  = {totalPauseTimeSpan.TotalMilliseconds}");
            Console.WriteLine($"   minuteTimerTimeLeft = {minuteTimerTimeLeft}");

            controller.State = PreviousState;
            controller.State.Start(minuteTimerTimeLeft, totalPauseTimeSpan);
        }
示例#4
0
 public override void SetNextState(PomodoroController controller)
 {
     controller.State = new LazerFocused();
 }
示例#5
0
 public override void Pause(PomodoroController controller)
 {
     PauseImpl(controller);
 }
示例#6
0
 public override void SetNextState(PomodoroController controller)
 {
     controller.State = new ProgressChecking();
 }
示例#7
0
 public virtual void Start(PomodoroController controller)
 {
     throw new InvalidOperationException($"{nameof(Start)} not allowed from state '{GetType().Name}'!");
 }
示例#8
0
 protected void PauseImpl(PomodoroController controller)
 {
     controller.State = new Paused(this);
 }
 public override void SetNextState(PomodoroController controller)
 {
     controller.State = new Break();
 }