Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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");
        }