public void TestDispose_Context() { var testContext = new TestContext(); var testService = new TestDocumentService(testContext, indexService.Object, notificationService.Object, batchSize); var contextField = typeof(TestDocumentService).GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic); var contextValue = contextField.GetValue(testService); Assert.IsNotNull(contextField); Assert.IsNotNull(contextValue); testService.Dispose(); contextValue = contextField.GetValue(testService); Assert.IsNull(contextValue); }
public void TestDispose_NotificationService() { var disposableNotificationService = new Mock <IIndexNotificationService>(); disposableNotificationService.As <IDisposable>(); var testContext = new TestContext(); var testService = new TestDocumentService(testContext, indexService.Object, disposableNotificationService.Object, batchSize); var notificationServiceField = typeof(TestDocumentService).BaseType.GetField("notificationService", BindingFlags.Instance | BindingFlags.NonPublic); var notificationServiceValue = notificationServiceField.GetValue(testService); Assert.IsNotNull(notificationServiceField); Assert.IsNotNull(notificationServiceValue); testService.Dispose(); notificationServiceValue = notificationServiceField.GetValue(testService); Assert.IsNull(notificationServiceValue); }