public async Task ContestStorageCmdInteractor_DeleteContestAsync_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 = "234wsdfs" }; mockContestRepository.Setup(c => c.DeleteAsync(It.IsAny <string>())).Returns <bool>(x => Task.FromResult(new Result <bool>(false))); var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object); var result = await contestCmdInteractor.DeleteContestAsync(contest); // Name is empty Assert.IsTrue(result.IsFaulted); // Contest Flyoff Rounds is out of range contest.Name = "foo"; contest.NumberOfFlyoffRounds = -1; result = await contestCmdInteractor.DeleteContestAsync(contest); Assert.IsTrue(result.IsFaulted); // Contest Rounds is out of range contest.NumberOfFlyoffRounds = 0; contest.Rounds = null; result = await contestCmdInteractor.DeleteContestAsync(contest); // Contest Rounds is out of range Assert.IsTrue(result.IsFaulted); contest.Id = string.Empty; contest.Rounds = new Dictionary <int, Round>(); result = await contestCmdInteractor.DeleteContestAsync(contest); // Contest ID is invalid Assert.IsTrue(result.IsFaulted); }
public async Task ContestStorageCmdInteractor_DeleteContestAsync_HappyPath() { var id = "4354rs"; 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.DeleteAsync(It.IsAny <string>())).Returns <string>(x => Task.FromResult(new Result <bool>(true))); var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object); var result = await contestCmdInteractor.DeleteContestAsync(contest); Assert.IsFalse(result.IsFaulted); Assert.IsTrue(result.Value); }
public async Task ContestStorageCmdInteractor_DeleteContestAsync_NullParameters() { var contestCmdInteractor = new ContestStorageCmdInteractor(mockContestRepository.Object, mockLogger.Object); await contestCmdInteractor.DeleteContestAsync(null); }