Beispiel #1
0
        public void Ctor_MerakiDashboardClientSettings_Null_BaseAddress()
        {
            MerakiDashboardClientSettings merakiDashboardClientSettings = new MerakiDashboardClientSettings
            {
                BaseAddress = null,
                ApiKey      = "apiKey"
            };

            Assert.Throws <ArgumentNullException>("baseAddress", () => new MerakiDashboardClient(merakiDashboardClientSettings));
        }
Beispiel #2
0
        public void Ctor_MerakiDashboardClientSettings_Null_ApiKey(string apiKey)
        {
            MerakiDashboardClientSettings merakiDashboardClientSettings = new MerakiDashboardClientSettings
            {
                BaseAddress = new Uri("http://www.myserver.com"),
                ApiKey      = apiKey
            };

            Assert.Throws <ArgumentException>("apiKey", () => new MerakiDashboardClient(merakiDashboardClientSettings));
        }
        public async void TestMocking()
        {
            Organization organization = new Organization
            {
                Name = "White house",
                Id   = "Org Id"
            };
            Network network = new Network
            {
                Id             = "Network Id",
                Name           = "White House Network",
                NetworkType    = "Wireless",
                OrganizationId = organization.Id,
                Tags           = "tags",
                TimeZone       = "UTC-06:00"
            };
            Device device = new Device
            {
                Address      = "1600 Pennsylania Ave Washington DC",
                LanIpAddress = new IPAddress(new byte[] { 127, 0, 0, 1 }),
                Lattitude    = 38.8977,
                Longitude    = 77.0365,
                Mac          = "00:00:00:00:00:00",
                Model        = "MR33",
                Name         = "Presidential AP",
                NetworkId    = network.Id,
                Serial       = "AAAA-BBBB-CCCC",
                Tags         = "Tags"
            };

            MerakiDashboardClientSettings merakiDashboardClientSettings = new MerakiDashboardClientSettings
            {
                ApiKey      = "api key",
                BaseAddress = new Uri("http://myapi.com")
            };

            Mock <MerakiDashboardClient> merakiDashboardlientMock = new Mock <MerakiDashboardClient>(MockBehavior.Strict, merakiDashboardClientSettings);

            merakiDashboardlientMock.Setup(merakiDashboardClient => merakiDashboardClient.GetOrganizationsAsync())
            .Returns(Task.FromResult(new [] { organization }));
            merakiDashboardlientMock.Setup(merakiDashboardClient => merakiDashboardClient.GetOrganizationNetworksAsync(organization))
            .Returns(Task.FromResult(new[] { network }));
            merakiDashboardlientMock.Setup(merakiDashboardClient => merakiDashboardClient.GetNetworkDevicesAsync(network))
            .Returns(Task.FromResult(new[] { device }));
            // Required by mocking framework
            merakiDashboardlientMock.Protected().Setup("Dispose", true);

            using (MerakiDashboardClient merakiDashboardClient = merakiDashboardlientMock.Object)
            {
                Assert.Equal(new[] { device }, await GetDevicesInAnOrganization(merakiDashboardClient));
            }
            merakiDashboardlientMock.VerifyAll();
        }
Beispiel #4
0
        public void Ctor_MerakiDashboardClientSettings()
        {
            Uri          baseAddress = new Uri("http://www.myserver.com");
            const string apiKey      = "000111222333444555666777888999000aaabbbbcccdddeee";

            MerakiDashboardClientSettings merakiDashboardClientSettings = new MerakiDashboardClientSettings
            {
                BaseAddress = baseAddress,
                ApiKey      = apiKey
            };

            using (MerakiDashboardClient merakiDashboardClient = new MerakiDashboardClient(merakiDashboardClientSettings))
            {
                Assert.Equal(baseAddress, merakiDashboardClient.Client.BaseAddress);
                Assert.Equal(apiKey, merakiDashboardClient.Client.ApiKey);
            }
        }