public void TestInit() { batchSize = 1; indexService = new Mock <IIndexService>(); notificationService = new Mock <IIndexNotificationService>(); context = new TestContext(); service = new TestDocumentService(context, indexService.Object, notificationService.Object, batchSize); }
public void TestConstructor_DefaultBatchSize() { var testService = new TestDocumentService(context, indexService.Object, notificationService.Object); Assert.IsNotNull(testService.GetContext()); Assert.IsFalse(testService.GetContext().Configuration.AutoDetectChangesEnabled); var batchSizeField = typeof(TestDocumentService).BaseType.GetField("batchSize", BindingFlags.Instance | BindingFlags.NonPublic); var batchSizeValue = batchSizeField.GetValue(testService); Assert.AreEqual(DocumentService <TestContext, SimpleEntity> .DEFAULT_BATCH_SIZE, batchSizeValue); }
public void TestConstructor() { var batchSize = 10; var testService = new TestDocumentService(context, indexService.Object, notificationService.Object, batchSize); Assert.IsNotNull(testService.GetContext()); Assert.IsFalse(testService.GetContext().Configuration.AutoDetectChangesEnabled); var batchSizeField = typeof(TestDocumentService).BaseType.GetField("batchSize", BindingFlags.Instance | BindingFlags.NonPublic); var batchSizeValue = batchSizeField.GetValue(testService); Assert.AreEqual(batchSize, batchSizeValue); }
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); }