public void Constructor_InitializesItems_ToStoreValue()
        {
            _store.SetState(AppState.SampleState);
            var sut = new ItemListViewModel(_store);

            Assert.Equal(AppState.SampleState.Items.Count, sut.Items.Count);
        }
Exemple #2
0
        public async Task FetchTilesRequest_FakeHttpClient()
        {
            // Arrange
            var request  = new TilesState.FetchTilesRequest();
            var response = "<head><meta property=\"og:title\" content=\"Microsoft launches Spend iOS app that automatically tracks and matches expenses\" />";

            response += "<meta property=\"og:image\" content=\"image\" />";
            response += "<meta property=\"og:description\" content=\"description\" /></head>";
            var mockStore = new MockStore();

            mockStore.SetState(new TilesState());
            var handler = new FetchTilesHandler(mockStore, Pocket(), TileMakerClient(response), GetPocketIOptions());

            // Act
            var result = await handler.Handle(request, CancellationToken.None);

            // Assert
            result.Should().NotBeNull();

            var state = mockStore.GetState <TilesState>();

            state.OriginalTiles.Should().NotBeNullOrEmpty();
            var first = state.OriginalTiles.First();

            first.Title.Should().NotBeNullOrWhiteSpace();
            first.Title.Should().Be("Microsoft launches Spend iOS app that automatically tracks and matches expenses");

            TestConsole.WriteLine(first.Title);
        }
Exemple #3
0
        public void Constructor_InitializesCounterValueToStoreValue()
        {
            _store.SetState(new AppState(99));
            var sut = new MainPageModel(_store);

            Assert.Equal(99, sut.CounterValue);
        }
Exemple #4
0
        public async Task IncrementCounterRequest_AmountDefined()
        {
            // Arrange
            var amount  = 7;
            var request = new CounterState.IncrementCounterRequest {
                Amount = amount
            };
            var mockStore = new MockStore();

            mockStore.SetState(new CounterState());
            var handler      = new CounterState.IncrementCounterHandler(mockStore);
            var initialCount = mockStore.GetState <CounterState>().Count;

            // Act
            var result = await handler.Handle(request, CancellationToken.None);

            // Assert
            result.Should().NotBeNull();
            var state = mockStore.GetState <CounterState>();

            state.Count.Should().Be(initialCount + amount);
        }
Exemple #5
0
        public async Task FetchTilesRequest_RealHttpClient()
        {
            // Arrange
            var request   = new TilesState.FetchTilesRequest();
            var mockStore = new MockStore();

            mockStore.SetState(new TilesState());
            var handler = new FetchTilesHandler(mockStore, Pocket(), RealTileMakerClient(), GetPocketIOptions());

            // Act
            var result = await handler.Handle(request, CancellationToken.None);

            // Assert
            result.Should().NotBeNull();
            var state = mockStore.GetState <TilesState>();

            state.OriginalTiles.Should().NotBeNullOrEmpty();

            foreach (var tile in state.OriginalTiles)
            {
                TestConsole.WriteLine(tile.Title);
            }
        }