예제 #1
0
        public void PostClocking(Clocking clocking)
        {
            var timeClock = TimeClockRepository.GetByUserName(clocking.UserName);

            if (timeClock == null)
                timeClock = new TimeClock(clocking.UserName);

            timeClock.AddTime(clocking.Date);

               TimeClockRepository.Store(timeClock);
        }
        public void PostClocking_WithoutKnownTimeClock_ShouldCreateATimeClock()
        {
            //arrange
            var clocking = new Clocking() { Date = "10-10-2012 11:11", UserName = "******" };
            var expectedTimeClock = new TimeClock(clocking.UserName);
            expectedTimeClock.AddTime(clocking.Date);

            var mockTimeClockRepository = new Moq.Mock<ITimeClockRepository>();
            mockTimeClockRepository.Setup(x => x.GetByUserName(clocking.UserName)).Returns<TimeClock>(null);
            mockTimeClockRepository.Setup(x => x.Store(expectedTimeClock));

            var clockingController = new ClockingController(mockTimeClockRepository.Object);

            //act
            clockingController.PostClocking(clocking);

            //assert
            mockTimeClockRepository.VerifyAll();
        }