Beispiel #1
0
 public DtoToEntitiesProfile()
 {
     CreateMap <CubeCoordinates, Cube>()
     .ConstructUsing((coord) =>
                     CubeFactory.Cube()
                     .WithCenterCoordinates(coord.X, coord.Y, coord.Z)
                     .WithDimension(coord.Dimension)
                     .Build()
                     );
 }
Beispiel #2
0
        public void If_Cubes_Are_Equal_Then_Intersection_Is_Equal_To_Volume()
        {
            var cube = CubeFactory
                       .Cube()
                       .WithCenterCoordinates(0, 0, 0)
                       .WithDimension(1)
                       .Build();

            //ACT
            var result = cube.Intersection(cube);

            //ASSERT
            Assert.AreEqual(GetCubeVolume(cube), result);
        }
Beispiel #3
0
        public void If_Cubes_Have_Same_Center_Then_Collide()
        {
            //ARRANGE
            var cube = CubeFactory
                       .Cube()
                       .WithCenterCoordinates(0, 0, 0)
                       .WithDimension(1)
                       .Build();

            //ACT
            var result = cube.Collides(cube);

            //ASSERT
            Assert.IsTrue(result);
        }
Beispiel #4
0
        public void If_Cubes_Dont_Touch_Then_Volume_Is_Zero()
        {
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(1)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(4, 0, 0)
                             .WithDimension(1)
                             .Build();

            //ACT
            var result = firstCube.Intersection(secondCube);

            //ASSERT
            Assert.AreEqual(0, result);
        }
Beispiel #5
0
        public void Intersection_Is_Mutual()
        {
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(1)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(1, 0, 0)
                             .WithDimension(2)
                             .Build();

            //ACT
            var firstCubeIntersection  = firstCube.Intersection(secondCube);
            var secondCubeIntersection = secondCube.Intersection(firstCube);

            //ASSERT
            Assert.AreEqual(firstCubeIntersection, secondCubeIntersection);
        }
Beispiel #6
0
        public void If_Cubes_Almost_Touch_Then_Not_Collide()
        {
            //ARRANGE
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(1)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(1.001, 0, 0)
                             .WithDimension(1)
                             .Build();

            //ACT
            var result = firstCube.Collides(secondCube);

            //ASSERT
            Assert.IsFalse(result);
        }
Beispiel #7
0
        public void If_Cubes_Are_Near_Then_Collide()
        {
            //ARRANGE
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(2)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(2, 0, 0)
                             .WithDimension(3)
                             .Build();

            //ACT
            var result = firstCube.Collides(secondCube);

            //ASSERT
            Assert.IsTrue(result);
        }
Beispiel #8
0
        public void If_Cubes_Have_Same_Center_Then_Intersection_Equals_Smaller_Cube_Volume()
        {
            //ARRANGE
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(1)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(0, 0, 0)
                             .WithDimension(2)
                             .Build();

            //ACT
            var result = firstCube.Intersection(secondCube);

            //ASSERT
            Assert.AreEqual(GetCubeVolume(firstCube), result);
            Assert.AreNotEqual(GetCubeVolume(secondCube), result);
        }
Beispiel #9
0
        public void Not_Collision_Is_Mutual()
        {
            //ARRANGE
            var firstCube = CubeFactory
                            .Cube()
                            .WithCenterCoordinates(0, 0, 0)
                            .WithDimension(1)
                            .Build();

            var secondCube = CubeFactory
                             .Cube()
                             .WithCenterCoordinates(3, 3, 3)
                             .WithDimension(1)
                             .Build();

            //ACT
            var firstCubeCollision  = firstCube.Collides(secondCube);
            var secondCubeCollision = secondCube.Collides(firstCube);

            //ASSERT
            Assert.IsFalse(firstCubeCollision);
            Assert.IsFalse(secondCubeCollision);
        }