Пример #1
0
        public void ReadString_ResourceNameAndAssembly_ReturnsTheImageFromResource()
        {
            // Arrange
            var fakeComObject = new TestableComObjectStub();
            var commons       = new CommonUtils(fakeComObject);
            var utils         = commons.Resource;

            // Act
            var actualText = utils.ReadString("NetOffice.Tests.Data.SampleText.txt", Assembly.GetExecutingAssembly());

            // Assert
            Assert.AreEqual("Sample text resource file.", actualText);
        }
Пример #2
0
        public void ReadIcon_ResourceNameAndAssembly_ReturnsTheIconFromResource()
        {
            // Arrange
            var fakeComObject = new TestableComObjectStub();
            var commons       = new CommonUtils(fakeComObject);
            var utils         = commons.Resource;

            // Act
            var actualIcon = utils.ReadIcon("NetOffice.Tests.Data.SampleIcon.ico", Assembly.GetExecutingAssembly());

            // Assert
            Assert.IsNotNull(actualIcon);
            Assert.AreEqual(16, actualIcon.Height);
            Assert.AreEqual(16, actualIcon.Width);
        }
Пример #3
0
        public void ReadImage_ResourceNameAndAssembly_ReturnsTheImageFromResource()
        {
            // Arrange
            var fakeComObject = new TestableComObjectStub();
            var commons       = new CommonUtils(fakeComObject);
            var utils         = commons.Resource;

            // Act
            var actualImage = utils.ReadImage("NetOffice.Tests.Data.SampleImage.png", Assembly.GetExecutingAssembly());

            // Assert
            Assert.IsNotNull(actualImage);
            Assert.AreEqual(4, actualImage.Height);
            Assert.AreEqual(4, actualImage.Width);
            Assert.AreEqual(ImageFormat.Png, actualImage.RawFormat);
        }
Пример #4
0
        public void PowerPointApplication_SlideShowEventIsRaised_CallsHandlerWithCorrectObject(string expectedEventName, Type expectedParameterType, Action <EApplication_SinkHelper> action)
        {
            // Arrange
            var eventBinder     = new TestableComObjectStub();
            var connectionPoint = new ConnectionPointStub();

            var events = new EApplication_SinkHelper(eventBinder, connectionPoint);

            // Act
            action(events);
            var actualParametersPassToEvent = eventBinder.LastRaisedEventParameters;

            // Assert
            Assert.AreEqual(expectedEventName, eventBinder.LastRaisedEventName);

            CollectionAssert.IsNotEmpty(actualParametersPassToEvent);
            var actualParameter1 = actualParametersPassToEvent[0];

            Assert.IsInstanceOf(expectedParameterType, actualParameter1, $"Event '{expectedEventName}' parameter must be of type '{expectedParameterType.Name}'");
        }
Пример #5
0
        public void SlideShowBegin_EventRaised_CallsHandlerWithCorrectObject()
        {
            // Arrange
            var eventBinder     = new TestableComObjectStub();
            var connectionPoint = new ConnectionPointStub();

            var events     = new EApplication_SinkHelper(eventBinder, connectionPoint);
            var parameter1 = new FakeComObject();

            // Act
            events.SlideShowBegin(parameter1);
            var actualParametersPassToEvent = eventBinder.LastRaisedEventParameters;

            // Assert
            Assert.AreEqual("SlideShowBegin", eventBinder.LastRaisedEventName);

            CollectionAssert.IsNotEmpty(actualParametersPassToEvent);
            var actualParameter1 = actualParametersPassToEvent[0];

            Assert.IsInstanceOf <SlideShowWindow>(actualParameter1, "Event SlideShowBegin parameter must be of type SlideShowWindow.");
        }