Exemplo n.º 1
0
        public static void ClassInitialize(TestContext testContext)
        {
            User = new User()
            {
                Active   = true,
                AuthType = "Abiquo",
                AvailableVirtualDatacenters = "all",
                Description = "arbitrary-description",
                Email       = "*****@*****.**",
                FirstLogin  = false,
                Id          = EnterServer.TENANT_ID_DEFAULT_VALUE,
                Locale      = "en-us",
            };

            var enterpriseLink =
                new Current.LinkBuilder()
                .BuildHref(string.Format("https://abiquo.example.com/api/admin/enterprises/{0}", EnterServer.TENANT_ID_DEFAULT_VALUE))
                .BuildRel(Current.AbiquoRelations.ENTERPRISE)
                .BuildTitle("Abiquo")
                .GetLink();

            User.Links = new List <Link>()
            {
                enterpriseLink
            };

            // this must be inside ClassInitialize - otherwise the tests will only work one at a time
            Client = Mock.Create <Current.AbiquoClient>(Behavior.CallOriginal);
        }
Exemplo n.º 2
0
        public void TestInitialize()
        {
            Mock.Arrange(() => Client.CurrentUserInformation)
            .IgnoreInstance()
            .Returns(User);

            Mock.SetupStatic(typeof(AbiquoClientFactory));
            Mock.Arrange(() => AbiquoClientFactory.GetByVersion())
            .Returns(Client);
            Mock.Arrange(() => AbiquoClientFactory.GetByVersion(Arg.IsAny <string>()))
            .Returns(Client);

            // strange - the mock inside the PSCmdlet only works when we invoke the mocked methods here first
            // this seems to be related to the Lazy<T> we use to initialise the Abiquo client via the factory
            CurrentClient = ModuleConfiguration.Current.Client;
        }
        public static void ClassInitialize(TestContext testContext)
        {
            User = new User()
            {
                Active   = true,
                AuthType = "Abiquo",
                AvailableVirtualDatacenters = "all",
                Description = "arbitrary-description",
                Email       = "*****@*****.**",
                FirstLogin  = false,
                Id          = EnterServer.TENANT_ID_DEFAULT_VALUE,
                Locale      = "en-us",
            };

            // this must be inside ClassInitialize - otherwise the tests will only work one at a time
            Client = Mock.Create <CS.Abiquo.Client.v1.AbiquoClient>(Behavior.CallOriginal);
        }