コード例 #1
0
        public void ReturnIndex()
        {
            // Arrange
            var bus  = new Mock <IBusControl>();
            var repo = new Mock <ILicensesRepository>();

            repo.Setup(repo => repo.GetAllReservations())
            .Returns(ReservationTestData.Reservations);

            var service = new LicenseService(bus.Object, repo.Object);

            var controller = new LicensesController(service);

            // Act
            var result = controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <List <Licenses> >(viewResult.ViewData.Model);

            Assert.Equal(2, model.Count());

            //Assert.Equal("Tudor", model[0].Name);
            //Assert.Equal(WashMachineType.Gorenje, model[0].WashMachineType);
            //Assert.Equal("Tudor2", model[1].Name);
            //Assert.Equal(WashMachineType.Bosh, model[1].WashMachineType);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public async Task Setup()
        {
            context = await TestDatabase.GetDatabaseContext();

            mockAppsService = new MockAppsService(context);

            baseRequest = new BaseRequest();

            appRequest = new AppRequest()
            {
                Name        = "New Test App 3",
                DevUrl      = "https://localhost:8080",
                LiveUrl     = "https://TestApp3.com",
                License     = TestObjects.GetLicense(),
                RequestorId = 1,
                Paginator   = new Paginator()
            };

            sutSuccess = new LicensesController(mockAppsService.AppsServiceSuccessfulRequest.Object);
            sutFailure = new LicensesController(mockAppsService.AppsServiceFailedRequest.Object);
        }