Example #1
0
        public void FacilitySpace_RemoveValuable_ObserverNotified()
        {
            var space    = new FacilitySpace();
            var obs      = new SimpleObserver <FacilitySpace>();
            var valuable = new ValuableFacilityObject {
                Type = "Vase", ObjectLayer = ObjectLayer.LowerObject
            };

            space.Put(valuable);
            space.Subscribe(obs);

            space.Remove((IValuable)valuable);

            Assert.AreEqual(space, obs.LastUpdate);
        }
Example #2
0
        public void FacilitySpace_RemoveObjectLayer_ObserverNotified()
        {
            var space = new FacilitySpace();
            var obs   = new SimpleObserver <FacilitySpace>();
            var obj   = new FacilityObject {
                Type = "Floor", ObjectLayer = ObjectLayer.Ground
            };

            space.Put(obj);
            space.Subscribe(obs);

            space.Remove(ObjectLayer.Ground);

            Assert.AreEqual(space, obs.LastUpdate);
        }
Example #3
0
        public void FacilitySpace_ReplaceObjectInLayer_LaterObjectExistsInSpace()
        {
            var space  = new FacilitySpace();
            var street = new FacilityObject {
                Type = "Street", ObjectLayer = ObjectLayer.Ground
            };
            var floor = new FacilityObject {
                Type = "Floor", ObjectLayer = ObjectLayer.Ground
            };

            space.Put(street);
            space.Put(floor);

            Assert.AreEqual(floor, space.Ground);
        }
Example #4
0
        public void FacilitySpace_Portals_ReturnedCorrectly()
        {
            var space = new FacilitySpace
            {
                Ground      = CreatePortal("Manhole"),
                UpperObject = CreatePortal("DoubleDoorLeftSide"),
                Ceiling     = CreatePortal("VentilationShaft")
            };

            var portals = space.Portals.ToList();

            Assert.AreEqual(3, portals.Count());
            Assert.IsTrue(portals.Any(x => x.Type.Equals("Manhole")));
            Assert.IsTrue(portals.Any(x => x.Type.Equals("Manhole")));
            Assert.IsTrue(portals.Any(x => x.Type.Equals("DoubleDoorLeftSide")));
        }
Example #5
0
        public void FacilitySpace_ValuableInContainer_ReturnsCorrectly()
        {
            var space     = new FacilitySpace();
            var container = new ValuablesContainer {
                ObjectLayer = ObjectLayer.LowerObject
            };

            container.Put(new Valuable {
                Type = "Diamond"
            });
            space.Put(container);

            var valuables = space.Valuables.ToList();

            Assert.AreEqual(1, valuables.Count());
            Assert.IsTrue(valuables.Any(x => x.Type.Equals("Diamond")));
        }
Example #6
0
        public void FacilitySpace_NoValuableRemoved_ObserverNotNotified()
        {
            var space = new FacilitySpace();
            var obs   = new SimpleObserver <FacilitySpace>();
            var obj   = new FacilityObject {
                Type = "Floor", ObjectLayer = ObjectLayer.Ground
            };

            space.Put(obj);
            space.Subscribe(obs);

            space.Remove(new FacilityObject {
                Type = "Door"
            });

            Assert.AreEqual(0, obs.UpdateCount);
        }
Example #7
0
        public void FacilitySpace_Placeables_ReturnsCorrectly()
        {
            var space = new FacilitySpace
            {
                Ground          = CreateFacilityObject("Floor"),
                GroundPlaceable = CreateSecurityObject("PressureMat"),
                LowerPlaceable  = CreateSecurityObject("Turret"),
                UpperObject     = CreateSecurityObject("SecurityCamera"),
            };

            var placeables = space.Placeables.ToList();

            Assert.AreEqual(3, placeables.Count());
            Assert.IsTrue(placeables.Any(x => x.Type.Equals("PressureMat")));
            Assert.IsTrue(placeables.Any(x => x.Type.Equals("Turret")));
            Assert.IsTrue(placeables.Any(x => x.Type.Equals("SecurityCamera")));
        }
Example #8
0
 public void Init()
 {
     _layer               = new FacilityLayer();
     _sampleSpace         = new FacilitySpace();
     _sampleLowerValuable = new ValuableFacilityObject {
         Type = "CouchLeft", ObjectLayer = ObjectLayer.LowerObject
     };
     _sampleLowerValuable2 = new ValuableFacilityObject {
         Type = "CouchRight", ObjectLayer = ObjectLayer.LowerObject
     };
     _sampleUpperValuable = new ValuableFacilityObject {
         Type = "Wallet", ObjectLayer = ObjectLayer.UpperObject
     };
     _sampleGroundPortal = new FacilityPortal {
         Type = "Manhole", ObjectLayer = ObjectLayer.Ground
     };
     _sampleUpperPortal = new FacilityPortal {
         Type = "Door", ObjectLayer = ObjectLayer.UpperObject
     };
 }
Example #9
0
        public void FacilitySpace_CreateEmptySpace_HasFloor()
        {
            var space = new FacilitySpace();

            AssertSpaceContentsAre(space);
        }