コード例 #1
0
        public async Task testAsyncCommandReturnsCorrectErrorOnFailedServerCall()
        {
            dataServiceMock.Setup(s => s.MakeJsonWebRequestAsync(It.IsAny <string>()))
            .Returns(() => Task.Factory.StartNew(() =>
            {
                var child = Task.Factory.StartNew(() =>
                {
                    throw new HttpRequestException("Http request failure");
                }, TaskCreationOptions.AttachedToParent);
                return(String.Empty);
            }));
            deserializeServiceMock.Setup(s => s.DeserializeCompetitionList(It.IsAny <string>()))
            .Returns(() =>
            {
                return(new List <Competition> {
                    new Competition()
                    {
                        Name = "Failed"
                    }
                });
            });
            footballDataService = new FootballDataService(dataServiceMock.Object, deserializeServiceMock.Object);
            target = new SelectCompetitionViewModel(footballDataService, navigationServiceMock.Object);

            target.GetAvailableCompetitionsCommand.Execute(null);

            while (target.GetAvailableCompetitionsCommand.Execution.IsNotCompleted)
            {
            }

            Assert.IsFalse(target.GetAvailableCompetitionsCommand.Execution.IsSuccessfullyCompleted, "Task should not be successful");
            Assert.IsTrue(target.GetAvailableCompetitionsCommand.Execution.IsFaulted, "Task should be failed.");
            Assert.AreEqual("Http request failure", target.GetAvailableCompetitionsCommand.Execution.ErrorMessage, "Wrong error message");
        }
コード例 #2
0
 public void setUp()
 {
     //deserializeMock = new Mock<IDeserializeFootballDataService>();
     deserializeService = new DeserializeFootballDataService();
     dataServiceMock    = new Mock <IDataService>();
     target             = new FootballDataService(dataServiceMock.Object, deserializeService);
 }
コード例 #3
0
 public void setUp()
 {
     deserializeService  = new DeserializeFootballDataService();
     dataService         = new DataService();
     footballDataService = new FootballDataService(dataService, deserializeService);
 }
コード例 #4
0
 public FootballDataServiceTests()
 {
     _footballDataService = new FootballDataService();
 }