Esempio n. 1
0
        public void GetProperty_CachedProperty_Equals()
        {
            var mock = new Mock <IPropertyProvider>();

            mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "filesize")).Returns <PropertyItem>(null);

            var item = new ProcessorItem("Testing123", null);

            item.TryCachePropertyValue("filesize", new PropertyItem(21.23));

            var property = item.GetProperty(mock.Object, "filesize");

            Assert.NotNull(property); // If null, TryCachePropertyValue might not have worked.
            Assert.Equal(21.23, property.Value);
        }
Esempio n. 2
0
        public void Value_Changed_CacheCleared()
        {
            var mock = new Mock <IPropertyProvider>();

            mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "filesize")).Returns <PropertyItem>(null);

            var item = new ProcessorItem("Testing123", null);

            item.TryCachePropertyValue("filesize", new PropertyItem(21.23));

            item.Value = "Done.";

            var property = item.GetProperty(mock.Object, "filesize");

            Assert.Null(property);
        }
Esempio n. 3
0
        public void TryCachePropertyValue_NullPropertyName_ThrowsArgumentNullException()
        {
            var item = new ProcessorItem("Testing123", null);

            Assert.Throws <ArgumentNullException>(() => item.TryCachePropertyValue(null, new PropertyItem(21.23)));
        }