Example #1
0
        public void Add_ValidAdRequest_ReturnsAdResponse()
        {
            var request = _factory.GetAdRequest();

            var response = _service.Add(request);

            Assert.IsNotNull(response);
            Assert.AreSame(typeof(AdResponse), response.GetType());
        }
Example #2
0
        public void ModelNull_ShouldThrow()
        {
            var sut = new AdService(AdRepositoryMock.Object);

            void Act() => sut.Add(null);

            Assert.Throws <ArgumentNullException>(Act);
        }
Example #3
0
        public void ModelNotNull_ShouldAddToRepository()
        {
            // arrange
            var sut   = new AdService(AdRepositoryMock.Object);
            var model = new AddAdModel
            {
                Subject      = "subject",
                Body         = "body",
                EmailAddress = "email",
                PriceSek     = 500
            };

            // act
            sut.Add(model);
            // assert
            AdRepositoryMock.Verify(m => m.Add(It.IsAny <Ad>()));
        }