public void Create_ReturnsNewExtensionOptionsIfThereIsNoContextObjectForTheGivenKey() { // Arrange BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(); object dummyValue = null; Mock <IContextObjectsService> mockContextObjectsService = _mockRepository.Create <IContextObjectsService>(); mockContextObjectsService.Setup(c => c.TryGetContextObject(typeof(IDummyExtensionOptions), dummyBlockProcessor, out dummyValue)).Returns(false); ExtensionOptionsFactory <IDummyExtensionOptions, DummyExtensionOptions, IDummyBlockOptions> testSubject = CreateExtensionOptionsFactory(mockContextObjectsService.Object); // Act IDummyExtensionOptions result = testSubject.Create(dummyBlockProcessor); // Assert _mockRepository.VerifyAll(); Assert.IsType <DummyExtensionOptions>(result); }
public void Create_ReturnsIExtensionOptionsFromContextObjectsIfItExists() { // Arrange BlockProcessor dummyBlockProcessor = MarkdigTypesFactory.CreateBlockProcessor(); Mock <IContextObjectsService> mockContextObjectsService = _mockRepository.Create <IContextObjectsService>(); Mock <IDummyExtensionOptions> dummyExtensionOptions = _mockRepository.Create <IDummyExtensionOptions>(); object dummyValue = dummyExtensionOptions.Object; mockContextObjectsService.Setup(c => c.TryGetContextObject(typeof(IDummyExtensionOptions), dummyBlockProcessor, out dummyValue)).Returns(true); ExtensionOptionsFactory <IDummyExtensionOptions, DummyExtensionOptions, IDummyBlockOptions> testSubject = CreateExtensionOptionsFactory(mockContextObjectsService.Object); // Act IDummyExtensionOptions result = testSubject.Create(dummyBlockProcessor); // Assert _mockRepository.VerifyAll(); Assert.Same(dummyValue, result); }