public void GetLicensesBySoftwareId_ShouldReturnLicensesOfThisSoftware()
        {
            var controller = new LicensesController(GetDemoContext());

            var result = controller.GetLicensesBySoftwareId(1) as IQueryable<License>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count(), 2);
            Assert.AreEqual(result.FirstOrDefault().SoftwareId, 1);
        }
        public void GetLicenses_ShouldReturnAllLicenses()
        {
            var context = GetDemoContext();
            var controller = new LicensesController(context);

            var result = controller.GetLicenses() as IQueryable<LicenseViewModel>;

            Assert.IsNotNull(result);
            Assert.AreEqual(context.Licenses.Local.Count, result.Count());
        }
        public void PutLicense_ShouldReturnStatusCode()
        {
            var controller = new LicensesController(new TestLicenseManagerContext());
            var item = GetDemoItem();

            var result = controller.PutLicense(item.LicenseId, item) as StatusCodeResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(StatusCodeResult));
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
        public void PostLicense_ShouldReturnSameLicense()
        {
            var controller = new LicensesController(GetDemoContext());
            var item = GetDemoItem();

            var result = controller.PostLicense(item) as CreatedAtRouteNegotiatedContentResult<License>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.RouteName, "DefaultApi");
            Assert.AreEqual(result.RouteValues["id"], result.Content.LicenseId);
            Assert.AreEqual(result.Content.ActivationKey, item.ActivationKey);
        }
        public void GetLicense_ShouldReturnCorrectLicense()
        {
            var context = GetDemoContext();
            var item = GetDemoItem();
            context.Licenses.Add(item);
            var controller = new LicensesController(context);

            var result = controller.GetLicense(item.LicenseId) as OkNegotiatedContentResult<License>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.LicenseId, result.Content.LicenseId);
            Assert.AreEqual(item.ActivationKey, result.Content.ActivationKey);
        }
        public void DeleteLicense_ShouldReturnOk()
        {
            var context = GetDemoContext();
            var item = GetDemoItem();
            context.Licenses.Add(item);
            var controller = new LicensesController(context);

            var result = controller.DeleteLicense(item.LicenseId) as OkNegotiatedContentResult<License>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Content.LicenseId, item.LicenseId);
        }