public void PostSoftware_ShouldFail_WhenInvalidManufacturerId()
        {
            var controller = new SoftwaresController(new TestLicenseManagerContext());
            var item       = GetDemoSoftware();

            var result = controller.PostSoftware(item);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
Example #2
0
        public async void PostSoftware_Returns_OK()
        {
            var query = new SoftwaresController(context);

            var newSoftware = new Software {
                Id = 4, Name = "Bengal Tiger"
            };
            var result = await query.PostSoftware(newSoftware);  // async

            Assert.IsType <ActionResult <Software> >(result);
            Assert.IsType <CreatedAtActionResult>(result.Result);
        }
        public void PostSoftware_ShouldReturnSameSoftware()
        {
            var controller = new SoftwaresController(GetDemoContext());
            var item       = GetDemoSoftware();

            var result = controller.PostSoftware(item) as CreatedAtRouteNegotiatedContentResult <Software>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.RouteName, "DefaultApi");
            Assert.AreEqual(result.RouteValues["id"], result.Content.SoftwareId);
            Assert.AreEqual(result.Content.Name, item.Name);
        }
Example #4
0
        public async void PostSoftware_Add()
        {
            var query = new SoftwaresController(context);

            var newSoftware = new Software {
                Id = 4, Name = "Bengal Tiger"
            };

            var result = await query.PostSoftware(newSoftware); // async

            var added = await query.GetSoftware(4);             // async

            var resultGoodRequest = Assert.IsType <CreatedAtActionResult>(result.Result);
            var addedGoodRequest  = Assert.IsType <Software>(added.Value);

            Assert.Equal(newSoftware.Name, added.Value.Name);
            Assert.Equal(newSoftware.Id, added.Value.Id);
            Assert.Equal(newSoftware, added.Value);
            Assert.Equal(newSoftware, resultGoodRequest.Value);
            Assert.Equal(newSoftware, addedGoodRequest);
        }