示例#1
0
        public async Task Customers_within_100km_should_be_written_to_output()
        {
            var input       = new JsonFileCustomerSource(GetTestLocationDirectory("data/customers.txt"));
            var destination = new PlainTextCustomerDestination(GetTestLocationDirectory("output.txt"),
                                                               new NullLogger <PlainTextCustomerDestination>());

            var subject = new FindCustomersCommand(defaultConfiguration, input, destination, new NullLogger <FindCustomersCommand>());

            await subject.Execute();

            Assert.Equal(LineUtility.CombineWithLineBreak(
                             "4 Ian Kehoe",
                             "5 Nora Dempsey",
                             "6 Theresa Enright",
                             "8 Eoin Ahearn",
                             "11 Richard Finnegan",
                             "12 Christina McArdle",
                             "13 Olive Ahearn",
                             "15 Michael Ahearn",
                             "17 Patricia Cahill",
                             "23 Eoin Gallagher",
                             "24 Rose Enright",
                             "26 Stephen McArdle",
                             "29 Oliver Ahearn",
                             "30 Nick Enright",
                             "31 Alan Behan",
                             "39 Lisa Ahearn"),
                         File.ReadAllText(GetTestLocationDirectory("output.txt")));
        }
        public async Task Customer_information_can_be_searched_deserialized()
        {
            var stubJson = LineUtility.CombineWithLineBreak(
                "{\"latitude\": \"52.366037\", \"user_id\": 16, \"name\": \"Ian Larkin\", \"longitude\": \"-8.179118\"}",
                "{\"latitude\": \"54.0894797\", \"user_id\": 8, \"name\": \"Eoin Ahearn\", \"longitude\": \"-6.18671\"}");

            var subject = new TestSubject(stubJson);

            var customers = await subject.FindCustomers(c => c.Name.StartsWith("Ian"), c => c.UserId);

            Assert.Equal(new[] { "Ian Larkin" }, customers.Select(x => x.Name));
        }
示例#3
0
        public async Task Customers_are_correctly_formatted_in_outputfile()
        {
            var subject = new TestSubject(DefaultSize);

            await subject.WriteCustomers(new[]
            {
                new Customer(1, "Vladimir Makayev", 10.5, 99.4), new Customer(2, "John Doe", 10, 9)
            });


            Assert.Equal(LineUtility.CombineWithLineBreak("1 Vladimir Makayev", "2 John Doe"), subject.GetContents());
        }