Ejemplo n.º 1
0
        public void AddAsync_SurveyIsNull_ThrowsException()
        {
            var dbMock = new Mock <IApplicationDBContext>();

            var subject = new SurveyService(dbMock.Object);

            var ex = Helpers.Catch <ArgumentNullException>(() =>
            {
                subject.AddAsync(null).Wait();
            });

            Assert.AreEqual("newSurvey", ex.ParamName);
        }
Ejemplo n.º 2
0
        public void AddAsync_SurveyIsOK_AddsAndSaves()
        {
            var survey = new Survey()
            {
            };

            var dbMock         = new Mock <IApplicationDBContext>();
            var surveyDataMock = new Mock <DbSet <Survey> >();

            dbMock.SetupGet(d => d.Surveys).Returns(surveyDataMock.Object);

            var subject = new SurveyService(dbMock.Object);

            subject.AddAsync(survey).Wait();

            surveyDataMock.Verify(d => d.Add(survey));
            dbMock.Verify(d => d.SaveChangesAsync());
        }