コード例 #1
0
            public void WhenCorrectInputIsProvidedAndIntersectionIsReturned_ThenIntersectionResponseIsProperlyMappedToApplResponse()
            {
                // Arrange
                var cube = _fixture.Create <Entity.Shape.Cube>();

                var intersectorMock = new Mock <IIntersector <Entity.Shape.Cube, Entity.Shape.Cube> >();

                intersectorMock.Setup(i => i.GetIntersection(It.IsAny <Entity.Shape.Cube>(), It.IsAny <Entity.Shape.Cube>()))
                .Returns(cube);

                var intersectorRegistryMock = new Mock <IIntersectorRegistry>();

                intersectorRegistryMock.Setup(reg => reg.GetIntersector <Entity.Shape.Cube, Entity.Shape.Cube>())
                .Returns(intersectorMock.Object);

                var sut = new IntersectionService(intersectorRegistryMock.Object);

                // Act
                var result = sut.GetIntersection(_fixture.Create <Cube>(), _fixture.Create <Cube>());

                // Assert
                result.Intersection.CenterX.Should().Be(cube.Center.X);
                result.Intersection.CenterY.Should().Be(cube.Center.Y);
                result.Intersection.CenterZ.Should().Be(cube.Center.Z);
                result.Intersection.SizeX.Should().Be(cube.SizeX);
                result.Intersection.SizeY.Should().Be(cube.SizeY);
                result.Intersection.SizeZ.Should().Be(cube.SizeZ);
                result.Intersect.Should().BeTrue();
            }
コード例 #2
0
            public void WhenCorrectInputIsProvided_ThenMethodWorksProperlyWithItsDependencies()
            {
                // Arrange
                var cube = _fixture.Create <Entity.Shape.Cube>();

                var intersectorMock = new Mock <IIntersector <Entity.Shape.Cube, Entity.Shape.Cube> >();

                intersectorMock.Setup(i => i.GetIntersection(It.IsAny <Entity.Shape.Cube>(), It.IsAny <Entity.Shape.Cube>()))
                .Returns(cube);

                var intersectorRegistryMock = new Mock <IIntersectorRegistry>();

                intersectorRegistryMock.Setup(reg => reg.GetIntersector <Entity.Shape.Cube, Entity.Shape.Cube>())
                .Returns(intersectorMock.Object);

                var sut = new IntersectionService(intersectorRegistryMock.Object);

                // Act
                sut.GetIntersection(_fixture.Create <Cube>(), _fixture.Create <Cube>());

                // Assert
                intersectorMock.Verify(i => i.GetIntersection(It.IsAny <Entity.Shape.Cube>(), It.IsAny <Entity.Shape.Cube>()),
                                       Times.Once(), "Method GetIntersection of intersector should be called once.");

                intersectorRegistryMock.Verify(i => i.GetIntersector <Entity.Shape.Cube, Entity.Shape.Cube>(),
                                               Times.Once(), "Method GetIntersector of intersectorRegistry should be called once.");
            }
コード例 #3
0
            public void WhenIntersectionIsReturned_ThenIntersectionResponseValuesAreProperlyRounded()
            {
                // Arrange
                var cube = new Entity.Shape.Cube(
                    new Entity.Shape.Point3D(19.199999999999989, 10.269999999999989, 9.999999999999989),
                    5.400000000000010,
                    2.149999999999989,
                    -2.799999999999989);

                var intersectorMock = new Mock <IIntersector <Entity.Shape.Cube, Entity.Shape.Cube> >();

                intersectorMock.Setup(i => i.GetIntersection(It.IsAny <Entity.Shape.Cube>(), It.IsAny <Entity.Shape.Cube>()))
                .Returns(cube);

                var intersectorRegistryMock = new Mock <IIntersectorRegistry>();

                intersectorRegistryMock.Setup(reg => reg.GetIntersector <Entity.Shape.Cube, Entity.Shape.Cube>())
                .Returns(intersectorMock.Object);

                var sut = new IntersectionService(intersectorRegistryMock.Object);

                // Act
                var result = sut.GetIntersection(_fixture.Create <Cube>(), _fixture.Create <Cube>());

                // Assert
                result.Intersection.CenterX.Should().Be(19.2);
                result.Intersection.CenterY.Should().Be(10.27);
                result.Intersection.CenterZ.Should().Be(10);
                result.Intersection.SizeX.Should().Be(5.4);
                result.Intersection.SizeY.Should().Be(2.15);
                result.Intersection.SizeZ.Should().Be(-2.8);
                result.Intersect.Should().BeTrue();
            }
コード例 #4
0
            public void WhenCubeBIsNull_ThenThrowArgumentNullException()
            {
                // Arrange
                var sut   = new IntersectionService(null);
                var cubeA = _fixture.Create <Cube>();

                // Act
                Action action = () => sut.GetIntersection(cubeA, null);

                // Assert
                action.Should().Throw <ArgumentNullException>();
            }
コード例 #5
0
            public void WhenCorrectInputIsProvidedAndNoIntersectionIsReturned_ThenIntersectionResponseIsProperlyMappedToApplResponse()
            {
                // Arrange
                var intersectorMock = new Mock <IIntersector <Entity.Shape.Cube, Entity.Shape.Cube> >();

                intersectorMock.Setup(i => i.GetIntersection(It.IsAny <Entity.Shape.Cube>(), It.IsAny <Entity.Shape.Cube>()))
                .Returns((Entity.Shape.Cube)null);

                var intersectorRegistryMock = new Mock <IIntersectorRegistry>();

                intersectorRegistryMock.Setup(reg => reg.GetIntersector <Entity.Shape.Cube, Entity.Shape.Cube>())
                .Returns(intersectorMock.Object);

                var sut = new IntersectionService(intersectorRegistryMock.Object);

                // Act
                var result = sut.GetIntersection(_fixture.Create <Cube>(), _fixture.Create <Cube>());

                // Assert
                result.Intersect.Should().BeFalse();
            }