예제 #1
0
        public async Task RespondToEventTest()
        {
            var httpResponse = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.NoContent
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <string>(HttpStatusCode.NoContent);

            _mockDataService
            .Setup(m => m.PutAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <string>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var calendarEndpoint = new CalendarEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            var result = await calendarEndpoint.RespondToEvent(
                1,
                1,
                Enums.Calendar.EventResponses.Accepted);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);

            Assert.IsNull(result.Message);
            Assert.IsNull(result.Data);
            Assert.IsNull(result.Error);
        }
예제 #2
0
 private void Init(ApiOptions apiOptions)
 {
     Meta      = new MetaEndpoint(apiOptions);
     Alliance  = new AllianceEndpoint(apiOptions);
     Assets    = new AssetsEndpoint(apiOptions);
     Bookmarks = new BookmarksEndpoint(apiOptions);
     Calendar  = new CalendarEndpoint(apiOptions);
 }
예제 #3
0
        public async Task GetEventAttendees()
        {
            var stubbedData = new []
            {
                new EventAttendee()
                {
                    CharacterId = 1,
                    Response    = Enums.Calendar.EventResponses.Accepted
                },
                new EventAttendee()
                {
                    CharacterId = 2,
                    Response    = Enums.Calendar.EventResponses.Declined
                }
            };

            var httpResponse = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonSerializer.Serialize(stubbedData))
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <EventAttendee[]>(HttpStatusCode.OK, stubbedData);

            _mockDataService
            .Setup(m => m.GetAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <EventAttendee[]>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var calendarEndpoint = new CalendarEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            var result = await calendarEndpoint.GetEventAttendees(1, 1);

            Assert.IsNull(result.Error);
            Assert.IsNull(result.Message);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual(stubbedData, result.Data);
        }
예제 #4
0
        public async Task GetEvent()
        {
            var stubbedData = new Event(
                new DateTime(2021, 1, 31).ToString(),
                5,
                1,
                1,
                1,
                "Some Owner",
                Enums.Calendar.OwnerType.Character,
                Enums.Calendar.EventResponses.Declined,
                "Some text",
                "Some Title");

            var httpResponse = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonSerializer.Serialize(stubbedData))
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <Event>(HttpStatusCode.OK, stubbedData);

            _mockDataService
            .Setup(m => m.GetAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <Event>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var calendarEndpoint = new CalendarEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            var result = await calendarEndpoint.GetEvent(1, 1);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual(stubbedData, result.Data);
            Assert.IsNull(result.Error);
            Assert.IsNull(result.Message);
        }
예제 #5
0
        public async Task GetEventSummaryTest()
        {
            var stubbedData = new EventSummary[]
            {
                new EventSummary()
                {
                    Id         = 1,
                    Title      = "Fake Event",
                    EventDate  = new DateTime(2021, 1, 31).ToString(),
                    Response   = Enums.Calendar.EventResponses.Accepted,
                    Importance = 1
                }
            };
            var httpResponse = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonSerializer.Serialize(stubbedData))
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <EventSummary[]>(HttpStatusCode.OK, stubbedData);

            _mockDataService
            .Setup(m => m.GetAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <EventSummary[]>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var calendarEndpoint = new CalendarEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            var result = await calendarEndpoint.GetEventSummaries(1);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
            Assert.IsNotNull(result.Data);
            Assert.IsNull(result.Error);
            Assert.IsNull(result.Message);
            Assert.AreEqual(stubbedData, result.Data);
        }