public void ReturnExpectedActionResult(string result, TestClass1 payload, string message, Type expectedActionResultType) { var serRes = new ServiceResponse <TestClass1> { Result = result, Payload = payload, Message = message }; var r = ServiceResponseExtensions.ToActionResult(serRes, typeof(TestClass2), "default"); r.ShouldBeOfType(expectedActionResultType); }
public void Maps_OkObjectResult() { string id = "1", msg = "msg"; var serRes = new ServiceResponse <TestClass1> { Result = ServiceResult.Ok, Payload = new TestClass1 { Id = int.Parse(id) }, Message = msg }; var r = ServiceResponseExtensions.ToActionResult(serRes, typeof(TestClass2), "default"); var ok = r.ShouldBeOfType <OkObjectResult>(); ok.Value.GetPropertyValueByName <string>("message").ShouldBe(msg); var tc = ok.Value.GetPropertyValueByName <TestClass2>("data"); tc.Id.ShouldBe(id); }