public async Task ContestStorageCmdInteractor_CreateContestAsync_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        = string.Empty
            };

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

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

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

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

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

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

            // Contest Rounds is out of range
            Assert.IsTrue(result.IsFaulted);
        }
        public async Task ContestStorageCmdInteractor_CreateContestAsync_RepositoryFailure()
        {
            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
            };

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

            Assert.IsTrue(result.IsFaulted);
            Assert.IsNull(result.Value);
        }
 public async Task ContestStorageCmdInteractor_CreateContestAsync_NullParameters()
 {
     var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object);
     await contestCmdInteractor.CreateContestAsync(null);
 }