Exemple #1
0
        public void given_valid_data_then_round_created()
        {
            //Arrange
            var model = new RoundModel()
            {
                TeeTime = DateTime.Now.AddDays(-10)
            };

            //Act
            var result = _repo.CreateOrUpdateRound(model);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOf <RoundModel>(result);
            Assert.IsTrue(result.Id > 0);
            _idsToDelete.Add(result.Id);
            Assert.AreEqual(model.TeeTime, result.TeeTime);
        }
        public void given_new_round_then_round_created()
        {
            //Arrange
            var fakeRoundModel = new RoundModel()
            {
                Id      = 0,
                TeeTime = DateTime.Now
            };

            //Act
            var result = _repo.CreateOrUpdateRound(fakeRoundModel);

            //Assert
            A.CallTo(() => _fakeContext.Rounds.Add(A <Round> .Ignored)).MustHaveHappened();
            A.CallTo(() => _fakeContext.SaveChanges()).MustHaveHappened();
            Assert.AreEqual(2, _fakeContext.Rounds.Count());
            Assert.IsNotNull(result);
            Assert.AreEqual(fakeRoundModel.TeeTime, result.TeeTime);
        }