public void GetMapping() { var requester = new Mock <IMessageRequester>(); var service = new MdmEntityService <SourceSystem>("sourcesystem", requester.Object); var tpIdentifier = new MdmId { SystemName = "Trayport", Identifier = "A" }; var sourcesystem = new SourceSystem { Details = new SourceSystemDetails { Name = "Gas" }, Identifiers = new MdmIdList { new MdmId { SystemName = "Nexus", Identifier = "1", IsMdmId = true }, tpIdentifier, new MdmId { SystemName = "Endur", Identifier = "B" }, } }; var response = new WebResponse <SourceSystem> { Code = HttpStatusCode.OK, Message = sourcesystem, Tag = "1" }; requester.Setup(x => x.Request <SourceSystem>(It.IsAny <string>())).Returns(response); // Act var candidate = service.Map(1, "Trayport"); // Assert Assert.AreEqual(HttpStatusCode.OK, candidate.Code, "Code differs"); Assert.AreEqual(true, candidate.IsValid, "IsValid differs"); Assert.AreSame(tpIdentifier, candidate.Message, "Message differs"); }
public void GetMappingMissingEntity() { var requester = new Mock <IMessageRequester>(); var service = new MdmEntityService <SourceSystem>("sourcesystem", requester.Object); var response = new WebResponse <SourceSystem> { Code = HttpStatusCode.NotFound, IsValid = false, }; requester.Setup(x => x.Request <SourceSystem>(It.IsAny <string>())).Returns(response); // Act var candidate = service.Map(1, "Trayport"); // Assert Assert.AreEqual(HttpStatusCode.NotFound, candidate.Code, "Code differs"); Assert.AreEqual(false, candidate.IsValid, "IsValid differs"); }
public void GetMappingMissingSystemId() { var requester = new Mock<IMessageRequester>(); var service = new MdmEntityService<SourceSystem>("sourcesystem", requester.Object); var tpIdentifier = new MdmId { SystemName = "Trayport", Identifier = "A" }; var entity = new SourceSystem { Details = new SourceSystemDetails { Name = "Gas" }, Identifiers = new MdmIdList { new MdmId { SystemName = "Nexus", Identifier = "1", IsMdmId = true}, tpIdentifier, new MdmId { SystemName = "Endur", Identifier = "B"}, } }; var response = new WebResponse<SourceSystem> { Code = HttpStatusCode.OK, Message = entity, Tag = "1" }; requester.Setup(x => x.Request<SourceSystem>(It.IsAny<string>())).Returns(response); // Act var candidate = service.Map(1, "Fred"); // Assert Assert.AreEqual(HttpStatusCode.NotFound, candidate.Code, "Code differs"); Assert.AreEqual(false, candidate.IsValid, "IsValid differs"); }
public void GetMappingMissingEntity() { var requester = new Mock<IMessageRequester>(); var service = new MdmEntityService<SourceSystem>("sourcesystem", requester.Object); var response = new WebResponse<SourceSystem> { Code = HttpStatusCode.NotFound, IsValid = false, }; requester.Setup(x => x.Request<SourceSystem>(It.IsAny<string>())).Returns(response); // Act var candidate = service.Map(1, "Trayport"); // Assert Assert.AreEqual(HttpStatusCode.NotFound, candidate.Code, "Code differs"); Assert.AreEqual(false, candidate.IsValid, "IsValid differs"); }