Exemplo n.º 1
0
        public void AddEnquiry_WithEmptyName_ShouldThrowException()
        {
            //Arrange
            var testEnquiry = new Enquiry { Name = "", EmailAddress = "*****@*****.**" };
            var testGuid = Guid.NewGuid();
            _mockRepository.Setup(t => t.AddEnquiry(testEnquiry)).Returns(testGuid);

            //Act
            _serviceToTest.AddEnquiry(testEnquiry);
        }
Exemplo n.º 2
0
        // POST: /api/enquiry
        public Guid Post(EnquiryViewModel enquiryViewModel)
        {
            var enquiry = new Enquiry
            {
                CarAds = _carAdsService.GetById(enquiryViewModel.CarAdsId),
                EmailAddress = enquiryViewModel.EmailAddress,
                Name = enquiryViewModel.Name
            };

            return _enquiryService.AddEnquiry(enquiry);
        }
Exemplo n.º 3
0
        public ActionResult AddEnquiry(EnquiryViewModel enquiryViewModel)
        {
            var enquiry = new Enquiry
                          {
                              CarAds = _carAdsService.GetById(enquiryViewModel.CarAdsId),
                              EmailAddress = enquiryViewModel.EmailAddress,
                              Name = enquiryViewModel.Name
                          };

            _enquiryService.AddEnquiry(enquiry);
            return View(enquiry);
        }
Exemplo n.º 4
0
        public Guid AddEnquiry(Enquiry newEnquiry)
        {
            //validate entry
            //TODO: we can use better validation for this. such as Fluent validation
            if (String.IsNullOrEmpty(newEnquiry.Name) || String.IsNullOrEmpty(newEnquiry.EmailAddress))
            {
                //better to use custom exceptioin
                throw new ApplicationException("Name or Email can't be empty");
            }

            return _enquiryRepository.AddEnquiry(newEnquiry);
        }
Exemplo n.º 5
0
        public void AddEnquiry_ShouldCallRepository()
        {
            //Arrange
            var testEnquiry = new Enquiry{Name="test", EmailAddress="*****@*****.**"};
            var testGuid = Guid.NewGuid();
            _mockRepository.Setup(t => t.AddEnquiry(testEnquiry)).Returns(testGuid);

            //Act
            var result = _serviceToTest.AddEnquiry(testEnquiry);

            //Assert
            Assert.AreEqual(testGuid, result);
            _mockRepository.VerifyAll();
        }
Exemplo n.º 6
0
 public Guid AddEnquiry(Enquiry newEnquiry)
 {
     newEnquiry.Id = Guid.NewGuid();
     _mockDb.Add(newEnquiry);
     return newEnquiry.Id;
 }