Esempio n. 1
0
        public void ServiceCommandProcessorProcessReturnsOnlyNonNullResults()
        {
            var mockClient = new Mock <IFabricClientApplicationWrapper>();
            var command    = new ServiceCommandProcessor(mockClient.Object);

            mockClient
            .Setup(c => c.GetAsync(It.IsAny <IOperationDescription>(), It.IsAny <IOperationContext>()))
            .Returns(Task.FromResult <IFabricOperationResult>(null));
            mockClient
            .Setup(c => c.DeleteAsync(It.IsAny <IOperationDescription>(), It.IsAny <IOperationContext>()))
            .Throws(new Exception());
            var context      = new OperationContext(CancellationToken.None, TimeSpan.FromMinutes(1));
            var descriptions = new List <IOperationDescription>()
            {
                new StatelessServiceOperationDescription()
                {
                    OperationType           = OperationType.CreateOrUpdate,
                    OperationSequenceNumber = 0,
                    ResourceId = "/svc1"
                },
                new StatefulServiceOperationDescription()
                {
                    OperationType           = OperationType.Delete,
                    OperationSequenceNumber = 1,
                    ResourceId = "/svc1"
                }
            };

            var task = command.ProcessAsync(descriptions, context);

            Assert.AreEqual(task.Result.Count, 1);
        }
Esempio n. 2
0
        public void ServiceCommandProcessorProcessReturnsEmptyStatus()
        {
            var mockClient   = new Mock <IFabricClientApplicationWrapper>();
            var command      = new ServiceCommandProcessor(mockClient.Object);
            var descriptions = new List <IOperationDescription>();
            var context      = new OperationContext(CancellationToken.None, TimeSpan.FromMinutes(1));

            var task = command.ProcessAsync(descriptions, context);

            Assert.IsFalse(task.Result.Any(), "Processing empty list should return no results.");
        }
Esempio n. 3
0
        public void ServiceCommandProcessorProcessFaultsOnNull()
        {
            var mockClient = new Mock <IFabricClientApplicationWrapper>();
            var command    = new ServiceCommandProcessor(mockClient.Object);

            try
            {
                command.ProcessAsync(null, null).Wait();
                Assert.Fail($"Null {nameof(IOperationDescription)} did not throw an exception");
            }
            catch (AggregateException ae)
            {
                Assert.IsTrue(ae.InnerException != null);
                Assert.IsInstanceOfType(ae.InnerException, typeof(ArgumentNullException));
            }
        }