public void CreateEntity(MdmRequestInfo requestInfo) { var requester = new Mock <IMessageRequester>(); var service = new MdmEntityService <SourceSystem>("sourcesystem", requester.Object); var sourcesystem = new SourceSystem(); var response = new WebResponse <SourceSystem>() { Code = HttpStatusCode.OK, IsValid = true }; requester.Setup(x => x.Create("sourcesystem", sourcesystem, requestInfo ?? It.IsAny <MdmRequestInfo>())) .Returns(response); requester.Setup(x => x.Request <SourceSystem>(It.IsAny <string>())) .Returns(new WebResponse <SourceSystem> { IsValid = true, Code = HttpStatusCode.OK, Message = sourcesystem, }); // Act var result = (requestInfo == null) ? service.Create(sourcesystem) : service.Create(sourcesystem, requestInfo); // Assert Assert.AreEqual(HttpStatusCode.OK, result.Code, "Status code differ"); Assert.AreEqual(true, result.IsValid, "IsValid differ"); }
public void CreateEntity(MdmRequestInfo requestInfo) { var requester = new Mock<IMessageRequester>(); var service = new MdmEntityService<SourceSystem>("sourcesystem", requester.Object); var sourcesystem = new SourceSystem(); var response = new WebResponse<SourceSystem>() { Code = HttpStatusCode.OK, IsValid = true }; requester.Setup(x => x.Create("sourcesystem", sourcesystem, requestInfo ?? It.IsAny<MdmRequestInfo>())) .Returns(response); requester.Setup(x => x.Request<SourceSystem>(It.IsAny<string>())) .Returns(new WebResponse<SourceSystem> { IsValid = true, Code = HttpStatusCode.OK, Message = sourcesystem, }); // Act var result = (requestInfo == null) ? service.Create(sourcesystem) : service.Create(sourcesystem, requestInfo); // Assert Assert.AreEqual(HttpStatusCode.OK, result.Code, "Status code differ"); Assert.AreEqual(true, result.IsValid, "IsValid differ"); }
public void CreateEntityFails() { var requester = new Mock<IMessageRequester>(); var service = new MdmEntityService<SourceSystem>("sourcesystem", requester.Object); var fault = new Fault() { Message = "faulting" }; requester.Setup(x => x.Create<SourceSystem>(It.IsAny<string>(), It.IsAny<SourceSystem>(), It.IsAny<MdmRequestInfo>())).Returns(new WebResponse<SourceSystem>() { Code = HttpStatusCode.InternalServerError, IsValid = false, Fault = fault }); // Act var result = service.Create(new SourceSystem()); // Assert Assert.AreEqual(HttpStatusCode.InternalServerError, result.Code, "Status code differ"); Assert.AreEqual(false, result.IsValid, "IsValid differ"); Assert.AreEqual(fault, result.Fault, "Fault not returned"); }
public void CreateEntityFails() { var requester = new Mock <IMessageRequester>(); var service = new MdmEntityService <SourceSystem>("sourcesystem", requester.Object); var fault = new Fault() { Message = "faulting" }; requester.Setup(x => x.Create <SourceSystem>(It.IsAny <string>(), It.IsAny <SourceSystem>(), It.IsAny <MdmRequestInfo>())).Returns(new WebResponse <SourceSystem>() { Code = HttpStatusCode.InternalServerError, IsValid = false, Fault = fault }); // Act var result = service.Create(new SourceSystem()); // Assert Assert.AreEqual(HttpStatusCode.InternalServerError, result.Code, "Status code differ"); Assert.AreEqual(false, result.IsValid, "IsValid differ"); Assert.AreEqual(fault, result.Fault, "Fault not returned"); }