Given_no_products_currently_being_used_when_checking_for_product_clashes_then_none_are_found()
        {
            // Arrange
            var fixture = new SafeFixture();

            var spotToCheckForClashes = fixture.Create <Spot>();

            var infoForAllSpots = new Dictionary <Guid, SpotInfo>
            {
                [spotToCheckForClashes.Uid] = new SpotInfo {
                    Uid = spotToCheckForClashes.Uid
                }
            };

            var labrat = new ProductClashChecker(enabled: true);

            // Act
            IEnumerable <Spot> result = labrat.GetProductClashesForMultipleSpots(
                new List <Spot>(1)
            {
                spotToCheckForClashes
            },
                new List <Spot>(0),
                infoForAllSpots,
                ClashCodeLevel.Child
                );

            // Assert
            _ = result.Should().BeEmpty(becauseArgs: null);
        }
Пример #2
0
        Given_an_invalid_clash_code_level_when_checking_for_a_product_clash_then_an_exception_is_thrown()
        {
            const ClashCodeLevel invalidValue = (ClashCodeLevel)Int32.MinValue;

            // Assert
            var ex = Assert.Throws <InvalidOperationException>(() =>
            {
                // Arrange
                var fixture = new SafeFixture();
                var spotToCheckForClashes = fixture.Create <Spot>();

                var infoForAllSpots = new Dictionary <Guid, SpotInfo>
                {
                    [spotToCheckForClashes.Uid] = new SpotInfo {
                        Uid = spotToCheckForClashes.Uid
                    }
                };

                var labrat = new ProductClashChecker(enabled: true);

                // Act
                IEnumerable <Spot> result = labrat.GetProductClashesForSingleSpot(
                    spotToCheckForClashes,
                    new List <Spot>(0),
                    infoForAllSpots,
                    invalidValue
                    );
            });

            _ = ex.Message.Should().Contain(invalidValue.ToString(), becauseArgs: null);
        }
Пример #3
0
        Given_product_clash_checking_is_not_enabled_when_checking_for_product_clashes_then_none_are_found()
        {
            // Arrange
            var labrat = new ProductClashChecker(enabled: false);

            var fixture = new SafeFixture();

            // Act
            IEnumerable <Spot> result = labrat.GetProductClashesForSingleSpot(
                fixture.Create <Spot>(),
                new List <Spot>(0),
                new Dictionary <Guid, SpotInfo>(0),
                ClashCodeLevel.Child
                );

            // Assert
            _ = result.Should().BeEmpty(becauseArgs: null);
        }
        Given_a_similar_child_product_is_already_used_when_searching_for_a_child_clash_then_a_clash_is_found()
        {
            // Arrange
            var fixture = new SafeFixture();

            var spotToCheckForClashes = fixture.Create <Spot>();
            var nonClashingSpot       = fixture.Create <Spot>();

            var productCodeThatWillClash = fixture.Create <string>();

            var infoForAllSpots = new Dictionary <Guid, SpotInfo>
            {
                [spotToCheckForClashes.Uid] = new SpotInfo
                {
                    Uid = spotToCheckForClashes.Uid,
                    ProductClashCode = productCodeThatWillClash
                },
                [nonClashingSpot.Uid] = new SpotInfo
                {
                    Uid = nonClashingSpot.Uid
                }
            };

            var labrat = new ProductClashChecker(enabled: true);

            // Act
            IEnumerable <Spot> result = labrat.GetProductClashesForMultipleSpots(
                new List <Spot>(1)
            {
                spotToCheckForClashes
            },
                new List <Spot> {
                spotToCheckForClashes, nonClashingSpot
            },
                infoForAllSpots,
                ClashCodeLevel.Child
                );

            // Assert
            _ = result.Should().NotBeEmpty(becauseArgs: null);
        }