public void CreateContest_HappyPath()
        {
            // Create a fake Contest entity to simulate one being created in the UI
            Contest fakeContest = this.GetFakeContest();

            // Arrange for the mocks to return no existing contests in the database
            DbSet <Contest> mockSet = CustomTestUtils.FakeDbSet <Contest>(this.emptyContestList);

            this.dbContext.Contests.Returns(mockSet);

            // Call the method being tested
            Contest contest = this.service.CreateContest(fakeContest);

            // Assert that calls were made against the mock dbContext and that we have a result
            this.dbContext.Received(1).Add(Arg.Is <Contest>(x => x.Name == fakeContest.Name));
            this.dbContext.Received(1).SaveChanges();
            Assert.That(contest, Is.Not.Null);
        }
        public void CreateContest_DuplicateContest_Throws()
        {
            // This test ensures that the user will be prevented from saving a duplicate test as determined by
            // the same Name and ContestDate
            Contest fakeContest = this.GetFakeContest();

            // Arrange for the mocks to return an existing Contest that matches with the fake being saved
            Contest oneExisting = new Contest {
                Name = fakeContest.Name, ContestDate = fakeContest.ContestDate
            };
            DbSet <Contest> mockSet = CustomTestUtils.FakeDbSet <Contest>(new List <Contest> {
                oneExisting
            });

            this.dbContext.Contests.Returns(mockSet);

            Assert.Throws <InvalidOperationException>(() => this.service.CreateContest(fakeContest));

            this.dbContext.DidNotReceiveWithAnyArgs().SaveChanges();
        }