Ejemplo n.º 1
0
        public void WhenTwoPlacementsCloseAndOneHasServer_ThenPlacementIsMerged()
        {
            var p1 = new InstancePlacement(
                null,
                null,
                new DateTime(2020, 1, 1, 10, 0, 0),
                new DateTime(2020, 1, 1, 11, 0, 0));
            var p2 = new InstancePlacement(
                "server-1",
                SampleNodeType,
                new DateTime(2020, 1, 1, 11, 0, 50),
                new DateTime(2020, 1, 1, 12, 0, 0));

            Assert.IsTrue(p1.IsAdjacent(p2));

            var merged = p1.Merge(p2);

            Assert.AreEqual(
                new DateTime(2020, 1, 1, 10, 0, 0),
                merged.From);
            Assert.AreEqual(
                new DateTime(2020, 1, 1, 12, 0, 0),
                merged.To);
            Assert.AreEqual("server-1", merged.ServerId);
            Assert.AreEqual(SampleNodeType, merged.NodeType);
        }
Ejemplo n.º 2
0
        public void WhenTwoPlacementsNotClose_ThenPlacementIsNotMerged()
        {
            var p1 = new InstancePlacement(
                null,
                new DateTime(2020, 1, 1, 10, 0, 0),
                new DateTime(2020, 1, 1, 11, 0, 0));
            var p2 = new InstancePlacement(
                null,
                new DateTime(2020, 1, 1, 11, 2, 0),
                new DateTime(2020, 1, 1, 12, 0, 0));

            Assert.IsFalse(p1.IsAdjacent(p2));
        }
Ejemplo n.º 3
0
        public void WhenTwoPlacementsCloseAndBothHaveDifferentServers_ThenPlacementIsNotMerged()
        {
            var p1 = new InstancePlacement(
                "server2",
                new DateTime(2020, 1, 1, 10, 0, 0),
                new DateTime(2020, 1, 1, 11, 0, 0));
            var p2 = new InstancePlacement(
                "server1",
                new DateTime(2020, 1, 1, 11, 0, 50),
                new DateTime(2020, 1, 1, 12, 0, 0));

            Assert.IsFalse(p1.IsAdjacent(p2));
        }