public void HarvestRestClientCreatesClientUsingProperParameters()
        {
            var expectedBaseUrl   = @"https://subdomain.harvestapp.com/";
            var expectedUserAgent = @"harvest.net/1.0.0 (.NET 4.5.2)";
            var username          = "******";
            var password          = "******";

            var assemblyInfo     = new Mock <IAssemblyInformation>();
            var environmentInfo  = new Mock <IEnvironmentInformation>();
            var restSharpFactory = new Mock <IRestSharpFactory>();

            var restSharpClient = new Mock <IRestClient>();

            assemblyInfo.SetupGet(s => s.Version).Returns(new Version(1, 0, 0));
            environmentInfo.SetupGet(s => s.Version).Returns(new Version(4, 5, 2));
            restSharpFactory.Setup(
                s => s.GetWebClient(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>()))
            .Returns(restSharpClient.Object);

            IHarvestRestClient client = new HarvestRestClient("subdomain", username, password, assemblyInfo.Object, environmentInfo.Object, restSharpFactory.Object);

            restSharpFactory.Verify(
                v => v.GetWebClient(
                    It.Is <string>(i => i == expectedBaseUrl),
                    It.Is <string>(i => i == expectedUserAgent),
                    It.Is <string>(i => i == username),
                    It.Is <string>(i => i == password)),
                Times.Once());
        }
        public void HarvestRestClientCreatesClientUsingProperParameters()
        {
            var expectedBaseUrl = @"https://subdomain.harvestapp.com/";
            var expectedUserAgent = @"harvest.net/1.0.0 (.NET 4.5.2)";
            var username = "******";
            var password = "******";

            var assemblyInfo = new Mock<IAssemblyInformation>();
            var environmentInfo = new Mock<IEnvironmentInformation>();
            var restSharpFactory = new Mock<IRestSharpFactory>();

            var restSharpClient = new Mock<IRestClient>();

            assemblyInfo.SetupGet(s => s.Version).Returns(new Version(1, 0, 0));
            environmentInfo.SetupGet(s => s.Version).Returns(new Version(4, 5, 2));
            restSharpFactory
                .Setup(s => s.GetWebClient(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>()))
                .Returns(restSharpClient.Object);

            IHarvestRestClient client = new HarvestRestClient("subdomain", username, password,
                assemblyInfo.Object, environmentInfo.Object, restSharpFactory.Object);

            restSharpFactory.Verify(v => v.GetWebClient(
                It.Is<string>(i => i == expectedBaseUrl),
                It.Is<string>(i => i == expectedUserAgent),
                It.Is<string>(i => i == username),
                It.Is<string>(i => i == password)), Times.Once());
        }
Esempio n. 3
0
        public void RefreshToken_Succeeds()
        {
            var client = new HarvestRestClient("harvestdotnet", "CuJ3af_hylkRp4NvDe20yg", "3_-0j6mRXPSjOmNcGn2q73BHexU11jxbbPiwBXnpX1oJ92Yj7Sb22UYuE4uKkc5zZYMtXg5s2BXZsfmWbFo0fg", null);

            OAuth whatever = client.RefreshToken("Vjlz7xhW2p9HbzndrM0D1HnaGY7z0S1PKsXkHuQXD1xai4_GCe_fHLEqUgNfqy4Yeuize9KtBfZAo1g3TyMqmg");

            Assert.NotNull(whatever);
            Assert.NotNull(whatever.AccessToken);
        }
Esempio n. 4
0
        public void RefreshToken_Succeeds()
        {
            var client = new HarvestRestClient("harvestdotnet", "CuJ3af_hylkRp4NvDe20yg", "3_-0j6mRXPSjOmNcGn2q73BHexU11jxbbPiwBXnpX1oJ92Yj7Sb22UYuE4uKkc5zZYMtXg5s2BXZsfmWbFo0fg", null);

            IOAuth whatever = client.RefreshToken("Vjlz7xhW2p9HbzndrM0D1HnaGY7z0S1PKsXkHuQXD1xai4_GCe_fHLEqUgNfqy4Yeuize9KtBfZAo1g3TyMqmg");

            Assert.NotNull(whatever);
            Assert.NotNull(whatever.AccessToken);
        }
Esempio n. 5
0
        public void OAuth_Succeeds()
        {
            var client = new HarvestRestClient("harvestdotnet", "CuJ3af_hylkRp4NvDe20yg", "3_-0j6mRXPSjOmNcGn2q73BHexU11jxbbPiwBXnpX1oJ92Yj7Sb22UYuE4uKkc5zZYMtXg5s2BXZsfmWbFo0fg", 
                "PbAjhAeW--og-9FADcPm0GHSHuWEWFKYzCLLhi0SkeFYMzH61a1_DekV7ww8_5blaBTGctlhPu2znfD_RyCjPw");

            var list = client.ListClients();

            Assert.True(list != null, "Result list is null.");
            Assert.NotEqual(0, list.First().Id);
        }
Esempio n. 6
0
        public void OAuth_Succeeds()
        {
            var client = new HarvestRestClient("harvestdotnet", "CuJ3af_hylkRp4NvDe20yg", "3_-0j6mRXPSjOmNcGn2q73BHexU11jxbbPiwBXnpX1oJ92Yj7Sb22UYuE4uKkc5zZYMtXg5s2BXZsfmWbFo0fg",
                                               "PbAjhAeW--og-9FADcPm0GHSHuWEWFKYzCLLhi0SkeFYMzH61a1_DekV7ww8_5blaBTGctlhPu2znfD_RyCjPw");

            var list = client.ListClients();

            Assert.True(list != null, "Result list is null.");
            Assert.NotEqual(0, list.First().Id);
        }
Esempio n. 7
0
        public FactBase()
        {
            Username = ConfigurationManager.AppSettings["auth_username"];
            Subdomain = ConfigurationManager.AppSettings["auth_subdomain"];
            
            string password = ConfigurationManager.AppSettings["auth_password"];

            Api = new HarvestRestClient(Subdomain, Username, password);

            Initialize();
        }
Esempio n. 8
0
        public FactBase()
        {
            Username  = ConfigurationManager.AppSettings["auth_username"];
            Subdomain = ConfigurationManager.AppSettings["auth_subdomain"];

            string password = ConfigurationManager.AppSettings["auth_password"];

            Api = new HarvestRestClient(Subdomain, Username, password);

            Initialize();
        }
Esempio n. 9
0
        public FactBase()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Username  = ConfigurationManager.AppSettings["auth_username"];
            Subdomain = ConfigurationManager.AppSettings["auth_subdomain"];

            string password = ConfigurationManager.AppSettings["auth_password"];

            Api = new HarvestRestClient(Subdomain, Username, password);

            Initialize();
        }
Esempio n. 10
0
        public FactBase()
        {
            var idString = ConfigurationManager.AppSettings["MainAccountId"];

            UserId = int.Parse(idString);
            Token  = ConfigurationManager.AppSettings["MainApiToken"];

            var provider = new TestAuthDataProvider(UserId.ToString(), Token);

            Api = new HarvestRestClient(provider);

            Initialize();
        }
 public void HarvestRestClientWithAccessTokenCanBeCreatedWithNoErrors()
 {
     IHarvestRestClient client = new HarvestRestClient("subdomain", "clientId", "clientSecret", "accessToken");
 }
 public void HarvestRestClientWithBasicAuthCanBeCreatedWithNoErrors()
 {
     IHarvestRestClient client = new HarvestRestClient("subdomain", "username", "password");
 }
Esempio n. 13
0
 public void HarvestRestClientWithAccessTokenCanBeCreatedWithNoErrors()
 {
     IHarvestRestClient client = new HarvestRestClient("subdomain", "clientId", "clientSecret", "accessToken");
 }
Esempio n. 14
0
 public void HarvestRestClientWithBasicAuthCanBeCreatedWithNoErrors()
 {
     IHarvestRestClient client = new HarvestRestClient("subdomain", "username", "password");
 }