示例#1
0
        public void Parse_GivenNegativeModifiedValue_ReturnsCreator()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("creator2"));

            var sut = new CreatorParser();

            // Act
            Creator result = sut.Parse(json);

            // Assert
            Assert.AreEqual(null, result.Modified);
        }
示例#2
0
        public void GetResponse_ReturnsSuccessFalse_OnAuthError()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("auth-error"));

            var sut = new EventParser();

            // Act
            Response <Event> result = sut.GetResponse <Event>(json);

            // Assert
            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("InvalidCredentials", result.Code);
            Assert.AreEqual("The passed API key is invalid.", result.Status);
            Assert.IsNull(result.Data);
        }
示例#3
0
        public void GetResponse_ReturnsSuccessFalse_OnError()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("api-error"));

            var sut = new EventParser();

            // Act
            Response <Event> result = sut.GetResponse <Event>(json);

            // Assert
            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("409", result.Code);
            Assert.AreEqual("Limit greater than 100.", result.Status);
            Assert.IsNull(result.Data);
        }
示例#4
0
        public void GetResponse_ReturnsSuccessTrue_OnSuccess()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("event-success"));

            var sut = new EventParser();

            // Act
            Response <Event> result = sut.GetResponse <Event>(json);

            // Assert
            Assert.AreEqual(true, result.Success);
            Assert.AreEqual("200", result.Code);
            Assert.AreEqual("Success.", result.Status);
            Assert.IsNotNull(result.Data);
        }
示例#5
0
        public void Parse_ReturnsEvent()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("event"));

            var sut = new EventParser();

            // Act
            Event result = sut.Parse(json);

            // Assert
            Assert.AreEqual(116, result.Id);
            Assert.AreEqual("Acts of Vengeance!", result.Title);
            Assert.AreEqual("Loki sets about convincing the super-villains of Earth to attack heroes other than those they normally fight in an attempt to destroy the Avengers to absolve his guilt over inadvertently creating the team in the first place.", result.Description);

            Assert.AreEqual(2, result.Urls.Count);
            Assert.AreEqual("detail", result.Urls.First().Type);
            Assert.AreEqual("http://marvel.com/comics/events/116/acts_of_vengeance?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.First().Value);
            Assert.AreEqual("wiki", result.Urls.Last().Type);
            Assert.AreEqual("http://marvel.com/universe/Acts_of_Vengeance!?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.Last().Value);

            Assert.AreEqual(new DateTimeOffset(new DateTime(2013, 6, 28, 16, 31, 24), new TimeSpan(-4, 0, 0)), result.Modified);
            Assert.AreEqual(new DateTime(1989, 12, 10), result.Start);
            Assert.AreEqual(new DateTime(2008, 1, 4), result.End);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/9/40/51ca10d996b8b", result.Thumbnail.Path);
            Assert.AreEqual("jpg", result.Thumbnail.Extension);

            Assert.AreEqual(117, result.Creators.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/116/creators", result.Creators.CollectionUri);
            Assert.AreEqual(20, result.Creators.Items.Count);
            Assert.AreEqual("Jeff Albrecht", result.Creators.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/2707", result.Creators.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.First().Type);
            Assert.AreEqual("inker", result.Creators.Items.First().Role);
            Assert.AreEqual("John Byrne", result.Creators.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/1827", result.Creators.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.Last().Type);
            Assert.AreEqual("artist", result.Creators.Items.Last().Role);
            Assert.AreEqual(20, result.Creators.Returned);

            Assert.AreEqual(85, result.Characters.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/116/characters", result.Characters.CollectionUri);
            Assert.AreEqual(20, result.Characters.Items.Count);
            Assert.AreEqual("Alpha Flight", result.Characters.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1010370", result.Characters.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Characters.Items.First().Type);
            Assert.AreEqual(null, result.Characters.Items.First().Role);
            Assert.AreEqual("Dazzler", result.Characters.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1009267", result.Characters.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Characters.Items.Last().Type);
            Assert.AreEqual(null, result.Characters.Items.Last().Role);
            Assert.AreEqual(20, result.Characters.Returned);

            Assert.AreEqual(145, result.Stories.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/116/stories", result.Stories.CollectionUri);
            Assert.AreEqual(20, result.Stories.Items.Count);
            Assert.AreEqual("Cover #12960", result.Stories.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/12960", result.Stories.Items.First().ResourceUri);
            Assert.AreEqual("cover", result.Stories.Items.First().Type);
            Assert.AreEqual(null, result.Stories.Items.First().Role);
            Assert.AreEqual("Thieves Honor", result.Stories.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/14921", result.Stories.Items.Last().ResourceUri);
            Assert.AreEqual("interiorStory", result.Stories.Items.Last().Type);
            Assert.AreEqual(null, result.Stories.Items.Last().Role);
            Assert.AreEqual(20, result.Stories.Returned);

            Assert.AreEqual(52, result.Comics.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/116/comics", result.Comics.CollectionUri);
            Assert.AreEqual(20, result.Comics.Items.Count);
            Assert.AreEqual("Alpha Flight (1983) #79", result.Comics.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/12744", result.Comics.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Comics.Items.First().Type);
            Assert.AreEqual(null, result.Comics.Items.First().Role);
            Assert.AreEqual("Doctor Strange, Sorcerer Supreme (1988) #11", result.Comics.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/20170", result.Comics.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Comics.Items.Last().Type);
            Assert.AreEqual(null, result.Comics.Items.Last().Role);
            Assert.AreEqual(20, result.Comics.Returned);

            Assert.AreEqual(22, result.Series.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/116/series", result.Series.CollectionUri);
            Assert.AreEqual(20, result.Series.Items.Count);
            Assert.AreEqual("Alpha Flight (1983 - 1994)", result.Series.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/2116", result.Series.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Series.Items.First().Type);
            Assert.AreEqual(null, result.Series.Items.First().Role);
            Assert.AreEqual("Web of Spider-Man (1985 - 1995)", result.Series.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/2092", result.Series.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Series.Items.Last().Type);
            Assert.AreEqual(null, result.Series.Items.Last().Role);
            Assert.AreEqual(20, result.Series.Returned);

            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/240", result.Next.ResourceUri);
            Assert.AreEqual("Days of Future Present", result.Next.Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/233", result.Previous.ResourceUri);
            Assert.AreEqual("Atlantis Attacks", result.Previous.Name);
        }
        public void Parse_ReturnsSeries()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("series"));

            var sut = new SeriesParser();

            // Act
            Series result = sut.Parse(json);

            // Assert
            Assert.AreEqual(18454, result.Id);
            Assert.AreEqual("100th Anniversary Special (2014 - Present)", result.Title);
            Assert.AreEqual("Test description", result.Description);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454", result.ResourceUri);
            Assert.AreEqual(1, result.Urls.Count);
            Assert.AreEqual("detail", result.Urls.Single().Type);
            Assert.AreEqual("http://marvel.com/comics/series/18454/100th_anniversary_special_2014_-_present?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.Single().Value);
            Assert.AreEqual(2014, result.StartYear);
            Assert.AreEqual(2099, result.EndYear);
            Assert.AreEqual("Rated T", result.Rating);
            Assert.AreEqual("limited", result.Type);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2015, 1, 14, 8, 48, 32), new TimeSpan(-5, 0, 0)), result.Modified);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/b/40/image_not_available", result.Thumbnail.Path);
            Assert.AreEqual("jpg", result.Thumbnail.Extension);

            Assert.AreEqual(5, result.Creators.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454/creators", result.Creators.CollectionUri);
            Assert.AreEqual(5, result.Creators.Items.Count);
            Assert.AreEqual("Andy Lanning", result.Creators.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/485", result.Creators.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.First().Type);
            Assert.AreEqual("writer", result.Creators.Items.First().Role);
            Assert.AreEqual("David Lopez", result.Creators.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12392", result.Creators.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.Last().Type);
            Assert.AreEqual("penciller (cover)", result.Creators.Items.Last().Role);
            Assert.AreEqual(5, result.Creators.Returned);

            Assert.AreEqual(0, result.Characters.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454/characters", result.Characters.CollectionUri);
            Assert.AreEqual(0, result.Characters.Items.Count);
            Assert.AreEqual(0, result.Characters.Returned);

            Assert.AreEqual(10, result.Stories.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454/stories", result.Stories.CollectionUri);
            Assert.AreEqual(10, result.Stories.Items.Count);
            Assert.AreEqual("cover from 100th Anniversary Special (2014) #1", result.Stories.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/110101", result.Stories.Items.First().ResourceUri);
            Assert.AreEqual("cover", result.Stories.Items.First().Type);
            Assert.AreEqual(null, result.Stories.Items.First().Role);
            Assert.AreEqual("story from 100th Anniversary Special (2014) #5", result.Stories.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/110110", result.Stories.Items.Last().ResourceUri);
            Assert.AreEqual("interiorStory", result.Stories.Items.Last().Type);
            Assert.AreEqual(null, result.Stories.Items.Last().Role);
            Assert.AreEqual(10, result.Stories.Returned);

            Assert.AreEqual(5, result.Comics.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454/comics", result.Comics.CollectionUri);
            Assert.AreEqual(5, result.Comics.Items.Count);
            Assert.AreEqual("100th Anniversary Special (2014) #1", result.Comics.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/49008", result.Comics.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Comics.Items.First().Type);
            Assert.AreEqual(null, result.Comics.Items.First().Role);
            Assert.AreEqual("100th Anniversary Special (2014) #1", result.Comics.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/49007", result.Comics.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Comics.Items.Last().Type);
            Assert.AreEqual(null, result.Comics.Items.Last().Role);
            Assert.AreEqual(5, result.Comics.Returned);

            Assert.AreEqual(0, result.Events.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/18454/events", result.Events.CollectionUri);
            Assert.AreEqual(0, result.Events.Items.Count);
            Assert.AreEqual(0, result.Events.Returned);

            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/240", result.Next.ResourceUri);
            Assert.AreEqual("Days of Future Present", result.Next.Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/233", result.Previous.ResourceUri);
            Assert.AreEqual("Atlantis Attacks", result.Previous.Name);
        }
示例#7
0
        public void Parse_ReturnsCreator()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("creator"));

            var sut = new CreatorParser();

            // Act
            Creator result = sut.Parse(json);

            // Assert
            Assert.AreEqual(12844, result.Id);
            Assert.AreEqual("Aco", result.FirstName);
            Assert.AreEqual("Middle Name", result.MiddleName);
            Assert.AreEqual("Last Name", result.LastName);
            Assert.AreEqual("Suffix", result.Suffix);
            Assert.AreEqual("Aco", result.FullName);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2016, 4, 15, 16, 42, 10), new TimeSpan(-4, 0, 0)), result.Modified);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/b/40/image_not_available", result.Thumbnail.Path);
            Assert.AreEqual("jpg", result.Thumbnail.Extension);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12844", result.ResourceUri);

            Assert.AreEqual(2, result.Comics.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12844/comics", result.Comics.CollectionUri);
            Assert.AreEqual(2, result.Comics.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/55740", result.Comics.Items.First().ResourceUri);
            Assert.AreEqual("Squadron Supreme Vol. 2: Civil War II (Trade Paperback)", result.Comics.Items.First().Name);
            Assert.AreEqual(null, result.Comics.Items.First().Type);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/60051", result.Comics.Items.Last().ResourceUri);
            Assert.AreEqual("Uncanny X-Men Annual (2016) #1", result.Comics.Items.Last().Name);
            Assert.AreEqual(null, result.Comics.Items.Last().Type);
            Assert.AreEqual(2, result.Comics.Returned);

            Assert.AreEqual(2, result.Series.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12844/series", result.Series.CollectionUri);
            Assert.AreEqual(2, result.Series.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/20519", result.Series.Items.First().ResourceUri);
            Assert.AreEqual("Squadron Supreme Vol. 2: Civil War II (2016)", result.Series.Items.First().Name);
            Assert.AreEqual(null, result.Series.Items.First().Type);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/22014", result.Series.Items.Last().ResourceUri);
            Assert.AreEqual("Uncanny X-Men Annual (2016)", result.Series.Items.Last().Name);
            Assert.AreEqual(null, result.Series.Items.Last().Type);
            Assert.AreEqual(2, result.Series.Returned);

            Assert.AreEqual(2, result.Stories.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12844/stories", result.Stories.CollectionUri);
            Assert.AreEqual(2, result.Stories.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/122524", result.Stories.Items.First().ResourceUri);
            Assert.AreEqual("story from Squadron Supreme (2016)", result.Stories.Items.First().Name);
            Assert.AreEqual("interiorStory", result.Stories.Items.First().Type);
            Assert.AreEqual(null, result.Stories.Items.First().Role);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/130633", result.Stories.Items.Last().ResourceUri);
            Assert.AreEqual("cover from Uncanny X-Men Annual (2020) #1", result.Stories.Items.Last().Name);
            Assert.AreEqual("cover", result.Stories.Items.Last().Type);
            Assert.AreEqual(null, result.Stories.Items.Last().Role);
            Assert.AreEqual(2, result.Stories.Returned);

            Assert.AreEqual(0, result.Events.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/12844/events", result.Events.CollectionUri);
            Assert.AreEqual(0, result.Events.Items.Count);
            Assert.AreEqual(0, result.Events.Returned);

            Assert.AreEqual(1, result.Urls.Count);
            Assert.AreEqual("detail", result.Urls.Single().Type);
            Assert.AreEqual("http://marvel.com/comics/creators/12844/aco?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.Single().Value);
        }
示例#8
0
        public void Parse_ReturnsComic()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("comic"));

            var sut = new ComicParser();

            // Act
            Comic result = sut.Parse(json);

            // Assert
            Assert.AreEqual(21472, result.Id);
            Assert.AreEqual(0, result.DigitalId);
            Assert.AreEqual("Ultimate Spider-Man (Spanish Language Edition) (2000) #8", result.Title);
            Assert.AreEqual(8, result.IssueNumber);
            Assert.AreEqual("Variant description", result.VariantDescription);
            Assert.AreEqual("Test description", result.Description);
            Assert.AreEqual(null, result.Modified);
            Assert.AreEqual("TestIsbn0001", result.Isbn);
            Assert.AreEqual("TestUpc0001", result.Upc);
            Assert.AreEqual("TestDiamondCode0001", result.DiamondCode);
            Assert.AreEqual("TestEan0001", result.Ean);
            Assert.AreEqual("TestIssn0001", result.Issn);
            Assert.AreEqual("Comic", result.Format);
            Assert.AreEqual(0, result.PageCount);

            Assert.AreEqual(1, result.TextObjects.Count);
            Assert.AreEqual("issue_solicit_text", result.TextObjects.Single().Type);
            Assert.AreEqual("en-us", result.TextObjects.Single().Language);
            Assert.AreEqual("\"The Marvel Age of Comics continues! This time around, Spidey meets his match against such classic villains as Electro and the Lizard, and faces the return of one of his first foes: the Vulture! Plus: Spider-Man vs. the Living Brain, Peter Parker's fight with Flash Thompson, and the wall-crawler tackles the high-flying Human Torch!\"", result.TextObjects.Single().Text);

            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21472", result.ResourceUri);

            Assert.AreEqual(1, result.Urls.Count);
            Assert.AreEqual("detail", result.Urls.Single().Type);
            Assert.AreEqual("http://marvel.com/comics/issue/21472/ultimate_spider-man_spanish_language_edition_2000_8?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.Single().Value);

            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/5105", result.Series.ResourceUri);
            Assert.AreEqual("Ultimate Spider-Man (Spanish Language Edition) (2000 - 2001)", result.Series.Name);

            Assert.AreEqual(2, result.Variants.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/56155", result.Variants.First().ResourceUri);
            Assert.AreEqual("Old Man Logan (2016) #8", result.Variants.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/60075", result.Variants.Last().ResourceUri);
            Assert.AreEqual("Old Man Logan (2016) #8 (Albuquerque Death of X Variant)", result.Variants.Last().Name);

            Assert.AreEqual(0, result.Collections.Count);

            Assert.AreEqual(4, result.CollectedIssues.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/546", result.CollectedIssues.First().ResourceUri);
            Assert.AreEqual("Marvel Age Spider-Man (2004) #8", result.CollectedIssues.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/681", result.CollectedIssues.Last().ResourceUri);
            Assert.AreEqual("Marvel Age Spider-Man (2004) #5", result.CollectedIssues.Last().Name);

            Assert.AreEqual(2, result.Dates.Count);
            Assert.AreEqual("onsaleDate", result.Dates.First().Type);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2029, 12, 31), new TimeSpan(-5, 0, 0)), result.Dates.First().Date);
            Assert.AreEqual("focDate", result.Dates.Last().Type);
            Assert.AreEqual(null, result.Dates.Last().Date);

            Assert.AreEqual(1, result.Prices.Count);
            Assert.AreEqual("printPrice", result.Prices.Single().Type);
            Assert.AreEqual(2.25, result.Prices.Single().Price);

            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/b/40/image_not_available", result.Thumbnail.Path);
            Assert.AreEqual("jpg", result.Thumbnail.Extension);

            Assert.AreEqual(4, result.Images.Count);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/a/40/4bc689a4ce796", result.Images.First().Path);
            Assert.AreEqual("jpg", result.Images.First().Extension);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/9/20/4bc665483c3aa", result.Images.Last().Path);
            Assert.AreEqual("jpg", result.Images.Last().Extension);

            Assert.AreEqual(0, result.Creators.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21472/creators", result.Creators.CollectionUri);
            Assert.AreEqual(0, result.Creators.Items.Count);
            Assert.AreEqual(0, result.Creators.Returned);

            Assert.AreEqual(1, result.Characters.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21472/characters", result.Characters.CollectionUri);
            Assert.AreEqual(1, result.Characters.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011010", result.Characters.Items.Single().ResourceUri);
            Assert.AreEqual("Spider-Man (Ultimate)", result.Characters.Items.Single().Name);
            Assert.AreEqual(null, result.Characters.Items.Single().Type);
            Assert.AreEqual(null, result.Characters.Items.Single().Role);
            Assert.AreEqual(1, result.Characters.Returned);

            Assert.AreEqual(2, result.Stories.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21472/stories", result.Stories.CollectionUri);
            Assert.AreEqual(2, result.Stories.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/48972", result.Stories.Items.First().ResourceUri);
            Assert.AreEqual("Cover #48972", result.Stories.Items.First().Name);
            Assert.AreEqual("cover", result.Stories.Items.First().Type);
            Assert.AreEqual(null, result.Stories.Items.First().Role);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/48973", result.Stories.Items.Last().ResourceUri);
            Assert.AreEqual("Interior #48973", result.Stories.Items.Last().Name);
            Assert.AreEqual("interiorStory", result.Stories.Items.Last().Type);
            Assert.AreEqual(null, result.Stories.Items.Last().Role);
            Assert.AreEqual(2, result.Stories.Returned);

            Assert.AreEqual(0, result.Events.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21472/events", result.Events.CollectionUri);
            Assert.AreEqual(0, result.Events.Items.Count);
            Assert.AreEqual(0, result.Events.Returned);
        }
示例#9
0
        public void Parse_ReturnsCharacter()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("character"));

            var sut = new CharacterParser();

            // Act
            Character result = sut.Parse(json);

            // Assert
            Assert.AreEqual(1011334, result.Id);
            Assert.AreEqual("3-D Man", result.Name);
            Assert.AreEqual("Test description", result.Description);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2014, 4, 29, 14, 18, 17), new TimeSpan(-4, 0, 0)), result.Modified);
            Assert.AreEqual("http://i.annihil.us/u/prod/marvel/i/mg/c/e0/535fecbbb9784", result.Thumbnail.Path);
            Assert.AreEqual("jpg", result.Thumbnail.Extension);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011334", result.ResourceUri);

            Assert.AreEqual(12, result.Comics.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011334/comics", result.Comics.CollectionUri);
            Assert.AreEqual(12, result.Comics.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/21366", result.Comics.Items.First().ResourceUri);
            Assert.AreEqual("Avengers: The Initiative (2007) #14", result.Comics.Items.First().Name);
            Assert.AreEqual(null, result.Comics.Items.First().Type);
            Assert.AreEqual(null, result.Comics.Items.First().Role);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/10225", result.Comics.Items.Last().ResourceUri);
            Assert.AreEqual("Marvel Premiere (1972) #37", result.Comics.Items.Last().Name);
            Assert.AreEqual(null, result.Comics.Items.Last().Type);
            Assert.AreEqual(null, result.Comics.Items.Last().Role);
            Assert.AreEqual(12, result.Comics.Returned);

            Assert.AreEqual(3, result.Series.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011334/series", result.Series.CollectionUri);
            Assert.AreEqual(3, result.Series.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/1945", result.Series.Items.First().ResourceUri);
            Assert.AreEqual("Avengers: The Initiative (2007 - 2010)", result.Series.Items.First().Name);
            Assert.AreEqual(null, result.Series.Items.First().Type);
            Assert.AreEqual(null, result.Series.Items.First().Role);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/2045", result.Series.Items.Last().ResourceUri);
            Assert.AreEqual("Marvel Premiere (1972 - 1981)", result.Series.Items.Last().Name);
            Assert.AreEqual(null, result.Series.Items.Last().Type);
            Assert.AreEqual(null, result.Series.Items.Last().Role);
            Assert.AreEqual(3, result.Series.Returned);

            Assert.AreEqual(21, result.Stories.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011334/stories", result.Stories.CollectionUri);
            Assert.AreEqual(20, result.Stories.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/19947", result.Stories.Items.First().ResourceUri);
            Assert.AreEqual("Cover #19947", result.Stories.Items.First().Name);
            Assert.AreEqual("cover", result.Stories.Items.First().Type);
            Assert.AreEqual(null, result.Stories.Items.First().Role);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/54371", result.Stories.Items.Last().ResourceUri);
            Assert.AreEqual("Avengers: The Initiative (2007) #14, Spotlight Variant - Int", result.Stories.Items.Last().Name);
            Assert.AreEqual("interiorStory", result.Stories.Items.Last().Type);
            Assert.AreEqual(null, result.Stories.Items.Last().Role);
            Assert.AreEqual(20, result.Stories.Returned);

            Assert.AreEqual(1, result.Events.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/characters/1011334/events", result.Events.CollectionUri);
            Assert.AreEqual(1, result.Events.Items.Count);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/events/269", result.Events.Items.Single().ResourceUri);
            Assert.AreEqual("Secret Invasion", result.Events.Items.Single().Name);
            Assert.AreEqual(null, result.Events.Items.Single().Type);
            Assert.AreEqual(null, result.Events.Items.Single().Role);
            Assert.AreEqual(1, result.Events.Returned);

            Assert.AreEqual(3, result.Urls.Count);
            Assert.AreEqual("detail", result.Urls.First().Type);
            Assert.AreEqual("http://marvel.com/characters/74/3-d_man?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.First().Value);
            Assert.AreEqual("comiclink", result.Urls.Last().Type);
            Assert.AreEqual("http://marvel.com/comics/characters/1011334/3-d_man?utm_campaign=apiRef&utm_source=20f18f98d97b8d7b9733fa6bdcfaea77", result.Urls.Last().Value);
        }
        public void Parse_ReturnsStory()
        {
            // Arrange
            dynamic json = JObject.Parse(TestJson.Get("story"));

            var sut = new StoryParser();

            // Act
            Story result = sut.Parse(json);

            // Assert
            Assert.AreEqual(26, result.Id);
            Assert.AreEqual("Haunted by her own father's death, Elektra finds that killing her latest target's daughter Ñ the only witness to the murder Ñ is", result.Title);
            Assert.AreEqual("Test description", result.Description);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26", result.ResourceUri);
            Assert.AreEqual("story", result.Type);
            Assert.AreEqual(new DateTimeOffset(new DateTime(1969, 12, 31, 19, 0, 0), new TimeSpan(-5, 0, 0)), result.Modified);
            Assert.AreEqual(null, result.Thumbnail);

            Assert.AreEqual(2, result.Creators.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26/creators", result.Creators.CollectionUri);
            Assert.AreEqual(2, result.Creators.Items.Count);
            Assert.AreEqual("Yoshitaka Amano", result.Creators.Items.First().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/29", result.Creators.Items.First().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.First().Type);
            Assert.AreEqual("penciller", result.Creators.Items.First().Role);
            Assert.AreEqual("Greg Rucka", result.Creators.Items.Last().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/creators/28", result.Creators.Items.Last().ResourceUri);
            Assert.AreEqual(null, result.Creators.Items.Last().Type);
            Assert.AreEqual("writer", result.Creators.Items.Last().Role);
            Assert.AreEqual(2, result.Creators.Returned);

            Assert.AreEqual(0, result.Characters.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26/characters", result.Characters.CollectionUri);
            Assert.AreEqual(0, result.Characters.Items.Count);
            Assert.AreEqual(0, result.Characters.Returned);

            Assert.AreEqual(1, result.Series.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26/series", result.Series.CollectionUri);
            Assert.AreEqual(1, result.Series.Items.Count);
            Assert.AreEqual("Elektra & Wolverine: The Redeemer (1999)", result.Series.Items.Single().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/series/25", result.Series.Items.Single().ResourceUri);
            Assert.AreEqual(null, result.Series.Items.Single().Type);
            Assert.AreEqual(null, result.Series.Items.Single().Role);
            Assert.AreEqual(1, result.Series.Returned);

            Assert.AreEqual(1, result.Comics.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26/comics", result.Comics.CollectionUri);
            Assert.AreEqual(1, result.Comics.Items.Count);
            Assert.AreEqual("Elektra & Wolverine: The Redeemer (Hardcover)", result.Comics.Items.Single().Name);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/960", result.Comics.Items.Single().ResourceUri);
            Assert.AreEqual(null, result.Comics.Items.Single().Type);
            Assert.AreEqual(null, result.Comics.Items.Single().Role);
            Assert.AreEqual(1, result.Comics.Returned);

            Assert.AreEqual(0, result.Events.Available);
            Assert.AreEqual("http://gateway.marvel.com/v1/public/stories/26/events", result.Events.CollectionUri);
            Assert.AreEqual(0, result.Events.Items.Count);
            Assert.AreEqual(0, result.Events.Returned);

            Assert.AreEqual("http://gateway.marvel.com/v1/public/comics/960", result.OriginalIssue.ResourceUri);
            Assert.AreEqual("Elektra & Wolverine: The Redeemer (Hardcover)", result.OriginalIssue.Name);
        }