コード例 #1
0
        public FormProofAppLicense()
        {
            InitializeComponent();

            this.m_ServiceController = new LicenseController();
            this.m_ServiceController.ProofLicenseEvent += M_ImeiController_ProofLicenseEvent;
        }
コード例 #2
0
        public void PostNewLicenseTest()
        {
            var lic = new License
            {
                Id              = 5,
                Name            = "VCI ALL - 2 Year",
                Description     = "VCI ALL - 2 Year",
                TitleOfHardware = "M-VCI",
                LicenseType     = DataLayer.Enums.LicenseType.Subscription,
                Duration        = 2,
                DateCreated     = DateTime.Now,
                DateUpdated     = DateTime.Now,
                Status          = DataLayer.Enums.Status.Valid,
                ProdFamilyId    = 6,
                SubscriptionId  = 2,
                VersionId       = 10,
                ApplicationId   = 2,
                ProductTypeId   = 7
            };

            var controller = new LicenseController(MockLicenseRepo);

            var result = controller.Post(lic);

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
        }
コード例 #3
0
 public FormCreateAppLicense(AreaCodeInfo areaCode)
 {
     InitializeComponent();
     this.m_Area = areaCode;
     this.m_ServiceController = new LicenseController();
     this.m_ServiceController.CreateLicenceEvent += M_ServiceController_CreateLicenceKeyEvent;
 }
コード例 #4
0
        public void Validate_In_One_Computer()
        {
            var controller = new LicenseController();

            Assert.IsTrue(controller.Validated(new MockISerialNumber(1)));
            Assert.IsTrue(File.Exists(Path.Combine(DataDirectory, LicenseController.LicenseFileName)));
        }
コード例 #5
0
        public void Edit()
        {
            LicenseController        controller = new LicenseController();
            EditUserLicenseViewModel model      = new EditUserLicenseViewModel();

            int id = 0;

            try
            {
                controller.Edit(id); // soll Exception werfen
                Assert.Fail();       // fehlgeschlagen, wenn es hierhin kommt
            }
            catch (EntityException ex)
            {
                Assert.IsTrue(ex is EntityException);
            }
            finally
            {
                try
                {
                    controller.Edit(id, model); // soll Exception werfen
                }
                catch (EntityException ex)
                {
                    Assert.IsTrue(ex is EntityException);
                }
            }
        }
コード例 #6
0
        public void GetLicenseByIdTest()
        {
            var mockDependency = new Mock <ILicenseRepository>();

            mockDependency.Setup(x => x.GetById(1)).Returns(() => new LicenseModel
            {
                Id            = 1,
                IdClient      = 2,
                ClientName    = "testClientName",
                IsActive      = true,
                IdApplication = 1,
                Number        = "XXXX-XXXX-XXXX-XXXX"
            });

            // Act
            var controller = new LicenseController()
            {
                AppRepo = mockDependency.Object
            };

            // Assert
            var res = controller?.GetById(1);

            if (res?.Data != null)
            {
                Assert.AreEqual("OK", res.Description);
                Assert.AreEqual("testClientName", res.Data.ClientName);
                Assert.AreEqual(true, res.Data.IsActive);
                Assert.AreEqual("XXXX-XXXX-XXXX-XXXX", res.Data.Number);
            }
            else
            {
                Assert.AreEqual(1, 2);
            }
        }
コード例 #7
0
        public void PostReturnIdLicenseTest()
        {
            var mockDependency    = new Mock <ILicenseRepository>();
            var modelLicenseModel = new LicenseModel()
            {
                ClientName    = "test",
                IdClient      = 1,
                IdApplication = 5
            };
            var modelLicenses = new Licenses()
            {
                Number = "XXX-XXX-XXX-XXX",
                Id     = 0,
            };

            mockDependency.Setup(x => x.Insert(modelLicenses)).Returns(() => (bool)true);

            // Act
            var controller = new LicenseController
            {
                AppRepo = mockDependency.Object
            };

            // Assert
            var res = controller.PostReturnId(modelLicenseModel);

            if (res?.Data != null)
            {
                Assert.AreEqual(modelLicenses.Id, res.Data);
            }
            else
            {
                Assert.AreEqual(1, 2);
            }
        }
コード例 #8
0
        public void PostReturnIdErrorIdClientTest()
        {
            var mockDependency    = new Mock <ILicenseRepository>();
            var modelLicenseModel = new LicenseModel()
            {
                ClientName = "test",
            };
            var modelLicenses = new Licenses()
            {
                Number = "XXX-XXX-XXX-XXX",
                Id     = 1,
            };

            mockDependency.Setup(x => x.Insert(modelLicenses)).Returns(() => true);

            // Act
            var controller = new LicenseController()
            {
                AppRepo = mockDependency.Object
            };

            // Assert
            var res = controller.PostReturnId(modelLicenseModel);

            if (res?.Data != null)
            {
                Assert.AreEqual("Id Client is required", res.Description);
                Assert.AreEqual(0, res.Data);
            }
            else
            {
                Assert.AreEqual(1, 2);
            }
        }
コード例 #9
0
        public void PutLicense()
        {
            var mockDependency = new Mock <ILicenseRepository>();
            var model          = new LicenseModel()
            {
                ClientName    = "test",
                Id            = 5,
                IdApplication = 4
            };

            mockDependency.Setup(x => x.EditLicense(5, model)).Returns(() => true);

            // Act
            var controller = new LicenseController()
            {
                AppRepo = mockDependency.Object
            };

            // Assert
            var res = controller.Put(model);

            if (res?.Data != null)
            {
                Assert.AreEqual("OK", res.Description);
                Assert.AreEqual(true, res.Data);
            }
            else
            {
                Assert.AreEqual(1, 2);
            }
        }
コード例 #10
0
        private LicenseController CreateController(
            Mock <ILicenseExpressionSegmentator> segmentator = null,
            Mock <ILogger <LicenseController> > logger       = null,
            Mock <ILicenseFileService> licenseFileService    = null)
        {
            if (segmentator == null)
            {
                segmentator = new Mock <ILicenseExpressionSegmentator>();
            }

            if (logger == null)
            {
                logger = new Mock <ILogger <LicenseController> >();
            }

            if (licenseFileService == null)
            {
                licenseFileService = new Mock <ILicenseFileService>();
            }

            var controller      = new LicenseController(segmentator.Object, logger.Object, licenseFileService.Object);
            var httpContextMock = new Mock <HttpContextBase>();

            httpContextMock
            .SetupGet(ctx => ctx.Response)
            .Returns(Mock.Of <HttpResponseBase>());
            var controllerContext = new ControllerContext();

            controllerContext.HttpContext = httpContextMock.Object;
            controller.ControllerContext  = controllerContext;

            return(controller);
        }
コード例 #11
0
        public void PutLicenseWithoutIdTest()
        {
            var mockDependency = new Mock <ILicenseRepository>();
            var model          = new LicenseModel()
            {
                ClientName = "test"
            };

            mockDependency.Setup(x => x.EditLicense(1, model)).Returns(() => true);

            // Act
            var controller = new LicenseController()
            {
                AppRepo = mockDependency.Object
            };

            // Assert
            var res = controller.Put(model);

            if (res?.Data != null)
            {
                Assert.AreEqual("Error: Id license <= 0", res.Description);
                Assert.AreEqual(false, res.Data);
            }
            else
            {
                Assert.AreEqual(1, 2);
            }
        }
コード例 #12
0
        public void Validate_In_Two_Computer()
        {
            var controller = new LicenseController();

            controller.Validated(new MockISerialNumber(1));
            controller.Validated(new MockISerialNumber(2));
            Assert.AreEqual(2, controller.LisenceCount);
        }
コード例 #13
0
        public FormRegisterAppLicense(LicenceInfo license)
        {
            InitializeComponent();
            this.m_License = license;

            this.m_LicenseController           = new LicenseController();
            this.m_LicenseController.AddEvent += m_LicenseController_AddEvent;
        }
コード例 #14
0
 public void Setup()
 {
     MockPlug.DeregisterAll();
     _licenseBLMock     = new Mock <ILicenseBL>();
     _seatingBLMock     = new Mock <ISeatingBL>();
     _wikiId            = "bob";
     _licenseController = new LicenseController(_wikiId, _storagePlug, LogUtils.CreateLog <LicenseController>());
 }
コード例 #15
0
        public FormUpdateAppLicense(LicenceInfo license)
        {
            InitializeComponent();
            this.m_License = license;

            this.m_LicenseController            = new LicenseController();
            this.m_LicenseController.EditEvent += m_LicenseController_EditEvent;
        }
コード例 #16
0
        public void Index()
        {
            LicenseController controller = new LicenseController();

            RedirectToRouteResult result = (RedirectToRouteResult)controller.Index();

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Home", result.RouteValues["controller"]);
        }
コード例 #17
0
        public void Index()
        {
            using (var target = new LicenseController())
            {
                var result = target.Index() as ViewResult;

                result.Should().NotBeNull();
            }
        }
コード例 #18
0
        public void Validate_In_More_Than_Three_Computer()
        {
            var controller = new LicenseController();

            controller.Validated(new MockISerialNumber(1));
            controller.Validated(new MockISerialNumber(2));
            controller.Validated(new MockISerialNumber(3));
            controller.Validated(new MockISerialNumber(4));
        }
コード例 #19
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Switches to the UI thread in order to consume some services used in command initialization
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await RegisterVsServicesAsync();

            TaskErrorViewModel.Errors.Clear();
            SquiggleViewModel.Squiggles.Clear();

            mCommandController = new CommandController(this);

            CommandTestUtility.CommandController = mCommandController;

            var vsOutputWindow = VsServiceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            mOutputWindowController = new OutputWindowController();
            mOutputWindowController.Initialize(this, vsOutputWindow);

            mRunningDocTableEvents = new RunningDocTableEvents(this);
            mErrorWindowController = new ErrorWindowController(this);

            #region Get Pointer to IVsSolutionEvents

            if (VsServiceProvider.TryGetService(typeof(SVsSolution), out object vsSolutionService))
            {
                var vsSolution = vsSolutionService as IVsSolution;
                UnadviseSolutionEvents(vsSolution);
                AdviseSolutionEvents(vsSolution);
            }

            #endregion

            // Get the build and command events from DTE
            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                var dte2 = dte as DTE2;
                mBuildEvents   = dte2.Events.BuildEvents;
                mCommandEvents = dte2.Events.CommandEvents;
                mDteEvents     = dte2.Events.DTEEvents;
            }

            mSettingsHandler = new SettingsHandler();
            mSettingsHandler.InitializeSettings();

            await mCommandController.InitializeCommandsAsync(this);

            mSettingsProvider = new SettingsProvider();

            RegisterToEvents();

            LicenseController mLicenseController = new LicenseController();
            await mLicenseController.CheckLicenseAsync();

            await base.InitializeAsync(cancellationToken, progress);
        }
コード例 #20
0
        public void LogoutLicenseForPostTest()
        {
            LicenseController licenseController;

            licenseController = new LicenseController();
            licenseController.LogoutLicenseForPost((string)null, (string)null);
            Assert.IsNotNull((object)licenseController);
            Assert.AreEqual <string>("127.0.0.1", ((BaseService)licenseController).Server);
            Assert.AreEqual <int>(8080, ((BaseService)licenseController).Port);
        }
コード例 #21
0
        public void RegisterTest()
        {
            LicenseController licenseController;

            licenseController = new LicenseController();
            licenseController.Register((string)null, (string)null, 0);
            Assert.IsNotNull((object)licenseController);
            Assert.AreEqual <string>("127.0.0.1", ((BaseService)licenseController).Server);
            Assert.AreEqual <int>(8080, ((BaseService)licenseController).Port);
        }
コード例 #22
0
        public void DeleteTest1()
        {
            LicenseController licenseController;

            licenseController = new LicenseController();
            licenseController.Delete(0);
            Assert.IsNotNull((object)licenseController);
            Assert.AreEqual <string>("127.0.0.1", ((BaseService)licenseController).Server);
            Assert.AreEqual <int>(8080, ((BaseService)licenseController).Port);
        }
コード例 #23
0
        public FormAppLicenseManager()
        {
            InitializeComponent();

            this.m_LicenseController = new LicenseController();

            this.m_LicenseController.DeleteEvent        += m_LicenseController_DeleteEvent;
            this.m_LicenseController.LogoutLicenseEvent += m_LicenseController_LogoutLicenseEvent;
            this.m_LicenseController.QueryEvent         += m_LicenseController_QueryEvent;

            this.m_AreaCodeController             = new AreaCodeController();
            this.m_AreaCodeController.QueryEvent += m_AreaCodeController_QueryEvent;
        }
コード例 #24
0
        public async Task UpdateLicense_Works_Async()
        {
            var store = new Mock <LicenseStore>(MockBehavior.Strict);

            store.Setup(s => s.AddLicenseAsync(It.IsAny <XDocument>(), default)).Returns(Task.CompletedTask).Verifiable();
            var controller = new LicenseController(store.Object, NullLogger <LicenseController> .Instance);

            using (Stream licenseStream = new MemoryStream(Encoding.UTF8.GetBytes("<license></license>")))
            {
                var license = new FormFile(licenseStream, 0, licenseStream.Length, ".license", ".license");

                Assert.IsType <OkResult>(await controller.UpdateLicenseAsync(license, default).ConfigureAwait(false));
            }

            store.Verify();
        }
コード例 #25
0
        public void Delete()
        {
            try
            {
                LicenseController controller = new LicenseController();
                Customer_Modules  toDelete   = new Customer_Modules();
                int id = 0;

                RedirectToRouteResult result = (RedirectToRouteResult)controller.Delete(id);

                Assert.AreEqual("Index", result.RouteValues["action"]);
                Assert.AreEqual("Home", result.RouteValues["controller"]);

                controller.Delete(id, toDelete); // soll Exception werfen
                Assert.Fail();                   // fehlgeschlagen, wenn es hierhin kommt
            }
            catch (EntityException ex)
            {
                Assert.IsTrue(ex is EntityException);
            }
        }
コード例 #26
0
        public void Add()
        {
            try
            {
                LicenseController controller = new LicenseController();

                int id        = 0;
                var viewModel = new VersionR.Areas.Admin.ViewModels.AddUserLicenseViewModel();

                ViewResult result = controller.Add(id, viewModel) as ViewResult;

                // Aufruf der View wird erwartet, weil viewModel keine Informationen enthält
                Assert.IsNotNull(result);

                controller.Add(id); // soll Exception werfen
                Assert.Fail();      // fehlgeschlagen, wenn es hierhin kommt
            }
            catch (EntityException ex)
            {
                Assert.IsTrue(ex is EntityException);
            }
        }
コード例 #27
0
        public void GetTest1()
        {
            LicenseController licenseController;

            // 测试用例1
            licenseController = new LicenseController();
            licenseController.Get((Dictionary <string, object>)null);
            Assert.IsNotNull((object)licenseController);
            Assert.AreEqual <string>("127.0.0.1", ((BaseService)licenseController).Server);
            Assert.AreEqual <int>(8080, ((BaseService)licenseController).Port);

            // 测试用例2
            Dictionary <string, object> dictionary;

            licenseController = new LicenseController();
            dictionary        = new Dictionary <string, object>(0);
            dictionary[""]    = (object)null;
            licenseController.Get(dictionary);
            Assert.IsNotNull((object)licenseController);
            Assert.AreEqual <string>("127.0.0.1", ((BaseService)licenseController).Server);
            Assert.AreEqual <int>(8080, ((BaseService)licenseController).Port);
        }
コード例 #28
0
        private void UpdateVersion(string version)
        {
            GeneralSettingsModel generalSettingsModel = mSettingsProvider.GetGeneralSettingsModel();

            string currentVersion = PackageUtility.GetVersion();

            if (string.IsNullOrWhiteSpace(currentVersion) == false && 0 > string.Compare(version, currentVersion))
            {
                generalSettingsModel.Version = currentVersion;
                mSettingsProvider.SetGeneralSettingsModel(generalSettingsModel);

                mSettingsHandler.SaveSettings();

                FreeTrialController freeTrialController = new FreeTrialController();
                LicenseController   licenseController   = new LicenseController();
                if (licenseController.CheckLocalLicense())
                {
                    freeTrialController.MarkAsExpired();
                }

                ReleaseNotesView releaseNotesView = new ReleaseNotesView();
                releaseNotesView.Show();
            }
        }
コード例 #29
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Switches to the UI thread in order to consume some services used in command initialization
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await RegisterVsServicesAsync();

            mCommandController = new CommandController(this);
            CommandTestUtility.CommandController = mCommandController;

            var vsOutputWindow = VsServiceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            mOutputWindowController = new OutputWindowController();
            mOutputWindowController.Initialize(this, vsOutputWindow);

            mRunningDocTableEvents = new RunningDocTableEvents(this);
            mErrorWindowController = new ErrorWindowController(this);

            #region Get Pointer to IVsSolutionEvents

            if (VsServiceProvider.TryGetService(typeof(SVsSolution), out object vsSolutionService))
            {
                var vsSolution = vsSolutionService as IVsSolution;
                UnadviseSolutionEvents(vsSolution);
                AdviseSolutionEvents(vsSolution);
            }

            #endregion

            // Get the build and command events from DTE
            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                var dte2 = dte as DTE2;
                mBuildEvents   = dte2.Events.BuildEvents;
                mCommandEvents = dte2.Events.CommandEvents;
                mDteEvents     = dte2.Events.DTEEvents;
            }

            DispatcherHandler.Initialize(dte as DTE2);
            SettingsProvider.Initialize(this);

            // Detect the first install
            if (string.IsNullOrWhiteSpace(SettingsProvider.GeneralSettings.Version))
            {
                ShowToolbare(); // Show the toolbar on the first install
            }
            if (string.IsNullOrWhiteSpace(SettingsProvider.GeneralSettings.Version) ||
                0 > string.Compare(SettingsProvider.GeneralSettings.Version, "5.0.0"))
            {
                System.Diagnostics.Process.Start(new ProcessStartInfo("https://clangpowertools.com/blog/future-of-clang-power-tools.html"));
            }

            var currentVersion = PackageUtility.GetVersion();
            if (!string.IsNullOrWhiteSpace(currentVersion) &&
                0 > string.Compare(SettingsProvider.GeneralSettings.Version, currentVersion))
            {
                mOutputWindowController.Clear();
                mOutputWindowController.Show();
                mOutputWindowController.Write($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" +
                                              $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG");

                SettingsProvider.GeneralSettings.Version = currentVersion;
            }

            SettingsHandler.SaveGeneralSettings();

            await mCommandController.InitializeCommandsAsync(this);

            mLicenseController = new LicenseController();

            RegisterToEvents();
            await mLicenseController.CheckLicenseAsync();

            await base.InitializeAsync(cancellationToken, progress);
        }
コード例 #30
0
 public void TestCleanup()
 {
     licenseController = null;
 }