Esempio n. 1
0
        public void Match_unchanged_updated_missing_and_removed_price_episodes(
            List <PriceEpisode> priceEpisodes,
            string leftOverPriceEpisodeId,
            PriceEpisodeStatusCalculator sut)
        {
            var currentPriceEpisodes = new[]
            {
                new CurrentPriceEpisode //unchanged
                {
                    PriceEpisodeIdentifier = priceEpisodes[1].Identifier,
                    AgreedPrice            = priceEpisodes[1].AgreedPrice,
                },
                new CurrentPriceEpisode //updated
                {
                    PriceEpisodeIdentifier = priceEpisodes[2].Identifier,
                    AgreedPrice            = priceEpisodes[2].AgreedPrice + 1,
                },
                new CurrentPriceEpisode //removed
                {
                    PriceEpisodeIdentifier = leftOverPriceEpisodeId,
                },
            };

            var r = sut.Calculate(currentPriceEpisodes, priceEpisodes);

            r.Should().BeEquivalentTo(
                (priceEpisodes[0].Identifier, PriceEpisodeStatus.New),
                (priceEpisodes[1].Identifier, PriceEpisodeStatus.New),
                (priceEpisodes[2].Identifier, PriceEpisodeStatus.Updated),
                (leftOverPriceEpisodeId, PriceEpisodeStatus.Removed)
                );
        }
Esempio n. 2
0
        private static List <(string identifier, PriceEpisodeStatus status)> CalculatePriceEpisodeStatus(
            IEnumerable <DataLockEvent> dataLocks, IEnumerable <CurrentPriceEpisode> currentPriceEpisodes)
        {
            var calculator = new PriceEpisodeStatusCalculator();
            var changes    = calculator.Calculate(currentPriceEpisodes, dataLocks.SelectMany(x => x.PriceEpisodes));

            return(changes);
        }
Esempio n. 3
0
        public void When_price_episode_price_changes_then_return_Updated(
            PriceEpisode priceEpisode,
            PriceEpisodeStatusCalculator sut)
        {
            var currentPriceEpisodes = new[]
            {
                new CurrentPriceEpisode
                {
                    PriceEpisodeIdentifier = priceEpisode.Identifier,
                    AgreedPrice            = 999,
                }
            };

            var r = sut.Match(currentPriceEpisodes, priceEpisode);

            r.Should().Be(PriceEpisodeStatus.Updated);
        }
Esempio n. 4
0
        public void When_price_episode_is_stored_and_has_not_changed_then_return_New(
            PriceEpisode priceEpisode,
            PriceEpisodeStatusCalculator sut)
        {
            var currentPriceEpisodes = new[]
            {
                new CurrentPriceEpisode
                {
                    PriceEpisodeIdentifier = priceEpisode.Identifier,
                    AgreedPrice            = priceEpisode.AgreedPrice,
                }
            };

            var r = sut.Match(currentPriceEpisodes, priceEpisode);

            r.Should().Be(PriceEpisodeStatus.New);
        }
Esempio n. 5
0
        public void When_price_episode_cannot_be_found_then_return_New(
            PriceEpisode priceEpisode,
            PriceEpisodeStatusCalculator sut)
        {
            var currentPriceEpisodes = new[]
            {
                new CurrentPriceEpisode
                {
                    PriceEpisodeIdentifier = "something else",
                    AgreedPrice            = priceEpisode.AgreedPrice,
                }
            };

            var r = sut.Match(currentPriceEpisodes, priceEpisode);

            r.Should().Be(PriceEpisodeStatus.New);
        }