public async Task ContestStorageCmdInteractor_UpdateContestAsync_HappyPath()
        {
            var id          = "l23l4sdf";
            var contestName = "Foo";
            var date        = DateTimeOffset.Now;
            var contest     = new Contest
            {
                Name = contestName,
                NumberOfFlyoffRounds = 0,
                Rounds    = new Dictionary <int, Round>(),
                StartDate = date,
                EndDate   = date.AddDays(1),
                Type      = ContestType.F3K,
                Id        = id
            };

            mockContestRepository.Setup(c => c.UpdateAsync(It.IsAny <Contest>())).Returns <Contest>(x => Task.FromResult(new Result <Contest>(contest)));
            var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object);
            var result = await contestCmdInteractor.UpdateContestAsync(contest);

            Assert.IsFalse(result.IsFaulted);
            Assert.AreEqual(id, result.Value.Id);
            Assert.AreEqual(contestName, result.Value.Name);
            Assert.AreEqual(contest.NumberOfFlyoffRounds, result.Value.NumberOfFlyoffRounds);
            Assert.AreEqual(date, result.Value.StartDate);
            Assert.AreEqual(contest.Rounds.Count, result.Value.Rounds.Count);
        }
        public async Task ContestStorageCmdInteractor_UpdateContestAsync_BadContestObjectParameter()
        {
            var contest = new Contest
            {
                Name = string.Empty,
                NumberOfFlyoffRounds = 0,
                Rounds    = new Dictionary <int, Round>(),
                StartDate = DateTimeOffset.Now,
                EndDate   = DateTimeOffset.Now.AddDays(1),
                Type      = ContestType.F3K,
                Id        = "2323rsdfdfs"
            };

            mockContestRepository.Setup(c => c.UpdateAsync(It.IsAny <Contest>())).Returns <Contest>(null);

            var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object);
            var result = await contestCmdInteractor.UpdateContestAsync(contest);

            // Name is empty
            Assert.IsTrue(result.IsFaulted);

            contest.Name = "foo";
            contest.NumberOfFlyoffRounds = -1;
            result = await contestCmdInteractor.UpdateContestAsync(contest);

            // Contest Flyoff Rounds is out of range
            Assert.IsTrue(result.IsFaulted);

            contest.NumberOfFlyoffRounds = 0;
            contest.Rounds = null;
            result         = await contestCmdInteractor.UpdateContestAsync(contest);

            // Contest Rounds is out of range
            Assert.IsTrue(result.IsFaulted);

            contest.Id     = string.Empty;
            contest.Rounds = new Dictionary <int, Round>();
            result         = await contestCmdInteractor.UpdateContestAsync(contest);

            // Contest ID is invalid
            Assert.IsTrue(result.IsFaulted);
        }
 public async Task ContestStorageCmdInteractor_UpdateContestAsync_NullParameters()
 {
     var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object);
     await contestCmdInteractor.UpdateContestAsync(null);
 }