public void ServiceShouldSaveNewMakerspace() { //arrange Makerspace dummyMakerspace = new Makerspace { Id = 1 }; var mockMakerspaceRepository = new Mock <IMakerspaceRepository>(); mockMakerspaceRepository.Setup(ms => ms.AddAsync(It.IsAny <Makerspace>())); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(_ => _.Makerspaces).Returns(mockMakerspaceRepository.Object); MakerspaceService makerspaceService = new MakerspaceService(mockUnitOfWork.Object); //act var makerspaceSaved = makerspaceService.CreateMakerspace(dummyMakerspace).Result; makerspaceSaved.Should().NotBeNull(); makerspaceSaved.Should().Be(dummyMakerspace, "the makerspace that was saved should be returned by the service."); mockMakerspaceRepository.Verify(_ => _.AddAsync(It.IsAny <Makerspace>()), Times.Once); mockUnitOfWork.Verify(_ => _.CommitAsync(), Times.Once()); }
public void ThenIWantToCreateAMakerspace() { //act var makerspaceSaved = MakerspaceService.CreateMakerspace(DummyMakerspace).Result; makerspaceSaved.Should().NotBeNull(); makerspaceSaved.Should().Be(DummyMakerspace, "the makerspace that was saved should be returned by the service."); //mockMakerspaceRepository.Verify(_ => _.AddAsync(It.IsAny<Makerspace>()), Times.Once); //mockUnitOfWork.Verify(_ => _.CommitAsync(), Times.Once()); }