示例#1
0
        public void UpdatingExistingAnimeWorksCorrectly()
        {
            // arrange
            const string url  = "http://localhost:8654";
            const string path = "/api/animelist/update/0.xml";

            MalRouteBuilder.AdjustRoot(url);
            var httpMock = HttpMockRepository.At(url);

            httpMock.Stub(t => t.Post(path))
            .OK();

            var          animeDummy     = new Mock <AnimeUpdate>();
            var          userAnimeDummy = new UserListAnime();
            const string user           = "******";
            const string pass           = "******";
            var          fixture        = new DataPushWorkerFixture();
            var          userListDummy  = new UserList();

            fixture.ListRetrievalWorkerMock.Setup(t => t.RetrieveUserListAsync(user))
            .ReturnsAsync(userListDummy);
            userAnimeDummy.SeriesId = 0;
            userListDummy.Anime.Add(userAnimeDummy);

            var sut = fixture.Instance;

            // act
            var result = sut.PushAnimeDetailsToMal(animeDummy.Object, user, pass).Result;

            // assert
            result.Success.Should().BeTrue();
            result.ResponseStatusCode.Should().Be(HttpStatusCode.OK);
            httpMock.AssertWasCalled(x => x.Post(path));
        }