public void PutSoftware_ShouldFail_WhenDifferentId()
        {
            var controller = new SoftwaresController(new TestLicenseManagerContext());

            var badresult = controller.PutSoftware(999, GetDemoSoftware());

            Assert.IsInstanceOfType(badresult, typeof(BadRequestResult));
        }
        public void GetSoftware_ShouldReturnNotFound_WhenInvalidId()
        {
            var controller = new SoftwaresController(new TestLicenseManagerContext());

            var result = controller.GetSoftware(-1, 999);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
        public void GetSoftwares_ShouldReturnAllSoftwares()
        {
            var context = GetDemoContext();
            var controller = new SoftwaresController(context);

            var result = controller.GetSoftwares() as TestSoftwareDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(context.Softwares.Local.Count, result.Local.Count);
        }
        public void PutSoftware_ShouldReturnStatusCode()
        {
            var controller = new SoftwaresController(GetDemoContext());
            var item = GetDemoSoftware();

            var result = controller.PutSoftware(item.SoftwareId, item) as StatusCodeResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(StatusCodeResult));
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
        public void GetSoftware_ShouldReturnSoftwareWithSameId()
        {
            var context = GetDemoContext();
            var item = GetDemoSoftware();
            context.Softwares.Add(item);
            var controller = new SoftwaresController(context);

            var result = controller.GetSoftware(-1, item.SoftwareId) as OkNegotiatedContentResult<Software>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Content.SoftwareId, item.SoftwareId);
        }
        public void PutSoftware_ShouldFail_WhenInvalidManufacturerId()
        {
            var context = GetDemoContext();
            var item = GetDemoSoftware();
            context.Softwares.Add(item);
            var controller = new SoftwaresController(context);
            item.ManufacturerId = 999;

            var result = controller.PutSoftware(item.SoftwareId, item);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
        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);
        }
        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));
        }