public async void Task_GetAll_Return_OkResult() { //Arrange var controller = new OrderLinkController(MatchbookDbContextWithData); //var linkId = 1; //Act var data = controller.Get(); //Assert Assert.IsType <Task <ActionResult <List <OrderLinkSummary> > > >(data); }
public async void Task_GetLinkById_Return_NotFoundResult() { //Arrange var controller = new OrderLinkController(MatchbookDbContextWithData); var linkId = 1; //Act var data = controller.Get(1); //Assert Assert.IsType <NotFoundResult>(data); }
public async void Task_AddNewLink_Return_OkResult_Match() { //Arrange //var linkId = 1; var orderlinkrequest = new OrderLinkrequest { orderIds = "1,3", orderLinkname = "Test" }; var order = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order); MatchbookDbContextWithData.SaveChanges(); var order1 = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order1); MatchbookDbContextWithData.SaveChanges(); var order2 = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order2); MatchbookDbContextWithData.SaveChanges(); order2.ProductSymbol = order.ProductSymbol; order2.SubAccountId = order.SubAccountId; MatchbookDbContextWithData.Orders.Update(order2); MatchbookDbContextWithData.SaveChanges(); var controller = new OrderLinkController(MatchbookDbContextWithData); //Act var data = controller.Post(orderlinkrequest); //Assert Assert.IsType <HttpResponseMessage>(data); Assert.Equal(data.StatusCode, HttpStatusCode.Created); Assert.Equal(data.ReasonPhrase.TrimEnd(), "The Order Link has been created with Link Id" + 1); }
public async void Task_GetLinkById_Return_OKResult() { //Arrange var controller = new OrderLinkController(MatchbookDbContextWithData); var linkId = 1; var linkid = new OrderLink { LinkedOrders = new List <Order> { DataGenerator.NewOrder(), DataGenerator.NewOrder() }, LinkName = "Test" }; MatchbookDbContextWithData.OrderLink.Add(linkid); MatchbookDbContextWithData.SaveChanges(); //Act var data = controller.Get(linkId); //Assert Assert.IsType <OkObjectResult>(data); }
public async void Task_AddNewLink_Return_OkResult_NoMatch() { //Arrange //var linkId = 1; var orderlinkrequest = new OrderLinkrequest { orderIds = "1,2", orderLinkname = "Test" }; var order = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order); MatchbookDbContextWithData.SaveChanges(); var order1 = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order1); MatchbookDbContextWithData.SaveChanges(); var order2 = DataGenerator.NewOrder(); MatchbookDbContextWithData.Orders.Add(order2); MatchbookDbContextWithData.SaveChanges(); var controller = new OrderLinkController(MatchbookDbContextWithData); //Act var data = controller.Post(orderlinkrequest); //Assert Assert.IsType <HttpResponseMessage>(data); Assert.Equal(data.StatusCode, HttpStatusCode.OK); Assert.Equal(data.ReasonPhrase.TrimEnd(), "No Matching Item Found"); }