public void ShouldReturnNotFoundWhenMapRequestedWithInvalidNexusIdentifier() { // Given var mockValidationEngine = new Mock <IValidatorEngine>(); var mockMappingEngine = new Mock <IMappingEngine>(); var mockRepository = new Mock <IRepository>(); var mockSearchCache = new Mock <ISearchCache>(); var abcService = new AbcEntityTestService(mockValidationEngine.Object, mockMappingEngine.Object, mockRepository.Object, mockSearchCache.Object); // When var mappingRequest = new MappingRequest() { Identifier = "Three", SystemName = "Nexus", ValidAt = DateTime.Now }; var response = abcService.Map(mappingRequest); Assert.AreEqual(ErrorType.NotFound, response.Error.Type); }
public void ShouldGetEntityByIdWhenMapRequestedForNexusSystem() { // Given var mockValidationEngine = new Mock <IValidatorEngine>(); var mockMappingEngine = new Mock <IMappingEngine>(); var mockRepository = new Mock <IRepository>(); var mockSearchCache = new Mock <ISearchCache>(); var abcService = new AbcEntityTestService(mockValidationEngine.Object, mockMappingEngine.Object, mockRepository.Object, mockSearchCache.Object); // When var mappingRequest = new MappingRequest() { Identifier = "3", SystemName = "Nexus", ValidAt = DateTime.Now }; abcService.Map(mappingRequest); // Then mockRepository.Verify(x => x.FindOne <AbcEntity>(int.Parse(mappingRequest.Identifier))); }
public void ShouldFindMappingWhenMapRequestedForNonNexusSystems() { // Given var mockValidationEngine = new Mock <IValidatorEngine>(); var mockMappingEngine = new Mock <IMappingEngine>(); var mockRepository = new Mock <IRepository>(); var mockSearchCache = new Mock <ISearchCache>(); IQueryable <AbcEntityMapping> abcEntityMappingQueryObject = (new List <AbcEntityMapping> { new AbcEntityMapping() { System = new SourceSystem() { Name = "Endur" }, MappingValue = "EndurId-3", Validity = new DateRange(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1)) } }).AsQueryable(); var abcService = new AbcEntityTestService( mockValidationEngine.Object, mockMappingEngine.Object, mockRepository.Object, mockSearchCache.Object); // When var mappingRequest = new MappingRequest() { Identifier = "EndurId-3", SystemName = "Endur", ValidAt = DateTime.Now }; mockValidationEngine.Setup(x => x.IsValid <MappingRequest>(mappingRequest, It.IsAny <IList <IRule> >())).Returns(true); mockRepository.Setup(x => x.Queryable <AbcEntityMapping>()).Returns(abcEntityMappingQueryObject); abcService.Map(mappingRequest); // Then mockRepository.Verify(x => x.Queryable <AbcEntityMapping>()); }