예제 #1
0
        public void ShouldNotSendZeroEvents()
        {
            var restClientMock = new Mock <IRestClient>(MockBehavior.Strict);
            var facade         = new EdsmApiFacade(restClientMock.Object, TestCredentials.UserName, TestCredentials.Edsm.ApiKey);

            Assert.DoesNotThrowAsync(() => facade.PostLogEvents(new JObject[] { }));

            restClientMock.VerifyAll();
        }
예제 #2
0
        public void ShouldThrowExceptionIfMoreThan100Events()
        {
            var restClientMock = new Mock <IRestClient>(MockBehavior.Strict);
            var facade         = new EdsmApiFacade(restClientMock.Object, TestCredentials.UserName, TestCredentials.Edsm.ApiKey);

            var events = Enumerable.Range(1, 200).Select(i => new JObject()).ToArray();

            Assert.ThrowsAsync <ArgumentException>(() => facade.PostLogEvents(events));

            restClientMock.VerifyAll();
        }
예제 #3
0
        public void ShouldThrowOnError()
        {
            var restClientMock = new Mock <IRestClient>();

            restClientMock.Setup(c => c.PostAsync(It.IsAny <IDictionary <string, string> >())).Returns(Task.FromResult("{ \"msgnum\": 100}")).Verifiable();

            var facade = new EdsmApiFacade(restClientMock.Object, TestCredentials.UserName, TestCredentials.Edsm.ApiKey);

            var events = Enumerable.Range(1, 5).Select(i => new JObject()).ToArray();

            Assert.DoesNotThrowAsync(() => facade.PostLogEvents(events));

            restClientMock.Verify(c => c.PostAsync(It.IsAny <IDictionary <string, string> >()), Times.Once());
            restClientMock.Verify(c => c.PostAsync(It.IsAny <string>()), Times.Never());
        }