Example #1
0
        public void ShouldNotReturnACompany_WhenBadIdIsPassed()
        {
            var guid = Guid.NewGuid();
            //Arrange
            var mockedRepository = new Mock <IEfRepository <Company> >();
            var company          = new Company();

            mockedRepository.Setup(x => x.GetById(guid)).Returns(company);

            var mockedCompanyRepository = new Mock <IEfRepository <Company> >();
            var mockedJobRepository     = new Mock <IEfRepository <Job> >();
            var mockedJob        = new Mock <Job>();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var service          = new CreateAJobService(mockedCompanyRepository.Object, mockedJobRepository.Object, mockedJob.Object, mockedUnitOfWork.Object);

            //Act
            var result = service.GetCompany(Guid.NewGuid());

            //Assert
            Assert.IsNull(result);
        }
Example #2
0
        public void ShouldReturnACompany_WhenProperIdIsPassed()
        {
            //Arrange
            var guid             = Guid.NewGuid();
            var mockedRepository = new Mock <IEfRepository <Company> >();
            var company          = new Company();

            mockedRepository.Setup(x => x.GetById(guid)).Returns(company);

            var mockedJobRepository = new Mock <IEfRepository <Job> >();
            var mockedJob           = new Mock <Job>();
            var mockedUnitOfWork    = new Mock <IUnitOfWork>();
            var service             = new CreateAJobService(mockedRepository.Object, mockedJobRepository.Object, mockedJob.Object, mockedUnitOfWork.Object);

            //Act
            var result = service.GetCompany(guid);

            //Assert
            Assert.IsInstanceOf <Company>(result);
            Assert.AreEqual(company, result);
        }