Exemplo n.º 1
0
        public void Cake_List_Download_Failed()
        {
            //Arrange
            _unityContainer.RegisterInstance <INetworkHelper>(new FakeNetworkHelper(NetworkAccess.Internet));
            _unityContainer.RegisterInstance <IDownloadCakeList>(new FakeDownloadCakeList(FakeDownloadCakeList.Mode.ReturnsNull));

            //Act
            var downlodedCakeList = CakesHelper.GetCakeList().Result;

            //Assert
            Assert.AreEqual("Error retrieving cake list, please try again", downlodedCakeList.ErrorMessage);
        }
Exemplo n.º 2
0
        public void Cake_List_Download_Succeeds_List_Sorted_Duplicates_Removed()
        {
            //Arrange
            _unityContainer.RegisterInstance <INetworkHelper>(new FakeNetworkHelper(NetworkAccess.Internet));
            _unityContainer.RegisterInstance <IDownloadCakeList>(new DownloadCakeList());

            //Act
            var downlodedCakeList = CakesHelper.GetCakeList().Result;

            var cakes = downlodedCakeList.Cakes;

            //Assert
            //Do we have any entries in the cake list
            Assert.IsTrue(downlodedCakeList.Cakes.Count > 0, "List does not contain any entries as expected");

            //Error message should be empty
            Assert.AreEqual(string.Empty, downlodedCakeList.ErrorMessage, "Connectivity error message should be empty");

            //List sort check
            var expectedList = cakes.OrderBy(x => x.Title).ToList();

            Assert.IsTrue(expectedList.SequenceEqual(cakes), "List is not sorted as expected");
        }