Пример #1
0
        public void GetByID_OneItem_ReturnsApartmentBuilding()
        {
            // Arrange
            ApartmentBuilding building = new ApartmentBuilding {
                ID = 1, Name = "MyBuilding"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <ApartmentBuilding>(building));

            // Assert
            Assert.AreNotSame(building, _cache.GetByID(1));
        }
Пример #2
0
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            ApartmentBuilding building1 = new ApartmentBuilding {
                ID = 1, Name = "Building1"
            };
            ApartmentBuilding building2 = new ApartmentBuilding {
                ID = 2, Name = "Building2"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <ApartmentBuilding>(building1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <ApartmentBuilding>(building2));

            // Assert
            Assert.AreNotSame(building1, _cache.GetByID(1));
            Assert.AreNotSame(building2, _cache.GetByID(2));
        }
Пример #3
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            ApartmentBuilding building1 = new ApartmentBuilding {
                ID = 1, Name = "Building1"
            };
            ApartmentBuilding building2 = new ApartmentBuilding {
                ID = 2, Name = "Building2"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <ApartmentBuilding>(building1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <ApartmentBuilding>(building2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <ApartmentBuilding>(building1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); });
            Assert.AreNotSame(building2, _cache.GetByID(2));
        }