示例#1
0
        public void RoundsPricesToNearestUnit()
        {
            // Create an component that receives some data
            var component = host.AddComponent <Shortlist>(new Dictionary <string, object>
            {
                [nameof(Shortlist.Itineraries)] = new List <Itinerary>
                {
                    TestItinerary.Create("Fake Airways", price: 123.45m), // Round down
                    TestItinerary.Create("Test Airways", price: 456.78m), // Round up
                }
            });

            // Assert: Prices are displayed correctly
            Assert.Equal("Shortlist (2)", component.Find("h2").InnerText);
            Assert.Collection(component.FindAll("ul"),
                              item =>
            {
                Assert.Equal("Fake Airways", item.QuerySelector(".airline").InnerText);
                Assert.Equal("$123", item.QuerySelector(".price").InnerText);
            },
                              item =>
            {
                Assert.Equal("Test Airways", item.QuerySelector(".airline").InnerText);
                Assert.Equal("$457", item.QuerySelector(".price").InnerText);
            });
        }
示例#2
0
        public void ShowsSearchResults()
        {
            // Arrange: Prepare a reply from server
            var app   = host.AddComponent <Main>();
            var reply = new SearchReply();

            reply.Itineraries.Add(TestItinerary.Create("My Airline", 123));
            reply.Itineraries.Add(TestItinerary.Create("Another Airline", 456m));

            // Act: Click 'search'; receive reply
            app.Find(".search-submit").Click();
            host.WaitForNextRender(() => flightDataClient.SetResponse(reply));

            // Assert: Verify UI displays the data
            Assert.Equal("2 results", app.Find("#results-area .title h2").InnerText);
            Assert.Collection(app.FindAll("#results-area .search-result"),
                              item =>
            {
                Assert.Equal("$123", item.QuerySelector(".price h3").InnerText);
                Assert.Equal("My Airline", item.QuerySelector(".airline span").InnerText);
            },
                              item =>
            {
                Assert.Equal("$456", item.QuerySelector(".price h3").InnerText);
                Assert.Equal("Another Airline", item.QuerySelector(".airline span").InnerText);
            });
        }