Example #1
0
        public void DeleteNotificationAction()
        {
            this.CreateInboxHelperAsync().Wait();
            this.PostNotificationHelper(this.controller).Wait();
            var inbox = this.GetInboxItemsAsyncHelper().Result;

            this.controller.DeleteAsync(this.inboxId, inbox.Items[0].Location.AbsoluteUri).GetAwaiter().GetResult();

            var blobReference = this.container.GetBlockBlobReference(inbox.Items[0].Location.AbsoluteUri);

            Assert.False(blobReference.DeleteIfExists(), "The blob should have already been deleted.");
            inbox = this.GetInboxItemsAsyncHelper().Result;
            Assert.Empty(inbox.Items);
        }
Example #2
0
        public async Task <JsonResult> CreateAsync()
        {
            var inbox = InboxEntity.Create();

            this.InboxTable.AddObject(inbox);
            await this.InboxTable.SaveChangesWithMergeAsync(inbox);

            string messageReceivingEndpoint = this.GetAbsoluteUrlForAction("Slot", new { id = inbox.RowKey }).AbsoluteUri;
            var    result = new InboxCreationResponse {
                MessageReceivingEndpoint = messageReceivingEndpoint,
                InboxOwnerCode           = inbox.InboxOwnerCode,
            };

            return(new JsonResult {
                Data = result
            });
        }
Example #3
0
        private async Task CreateInboxHelperAsync()
        {
            var jsonResult = await this.controller.CreateAsync();

            var result = (InboxCreationResponse)jsonResult.Data;

            this.inbox = result;

            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);
            var httpContextMock = new Mock <HttpContextBase>();

            httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath)
            .Returns("~" + new Uri(result.MessageReceivingEndpoint).PathAndQuery);     // POST
            var routeData = routes.GetRouteData(httpContextMock.Object);

            this.inboxId = (string)routeData.Values["id"];
        }
		private async Task CreateInboxHelperAsync() {
			var jsonResult = await this.controller.CreateAsync();
			var result = (InboxCreationResponse)jsonResult.Data;
			this.inbox = result;

			var routes = new RouteCollection();
			RouteConfig.RegisterRoutes(routes);
			var httpContextMock = new Mock<HttpContextBase>();
			httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath)
				.Returns("~" + new Uri(result.MessageReceivingEndpoint).PathAndQuery); // POST
			var routeData = routes.GetRouteData(httpContextMock.Object);
			this.inboxId = (string)routeData.Values["id"];
		}
		public void DeleteNotificationAction() {
			this.CreateInboxHelperAsync().Wait();
			this.PostNotificationHelper().Wait();
			var inbox = this.GetInboxItemsAsyncHelper().Result;
			this.controller.DeleteAsync(this.inboxId, inbox.Items[0].Location.AbsoluteUri).GetAwaiter().GetResult();

			var blobReference = this.container.GetBlockBlobReference(inbox.Items[0].Location.AbsoluteUri);
			Assert.That(blobReference.DeleteIfExists(), Is.False, "The blob should have already been deleted.");
			inbox = this.GetInboxItemsAsyncHelper().Result;
			Assert.That(inbox.Items, Is.Empty);
		}
Example #6
0
        public async Task<JsonResult> CreateAsync()
        {
            var inbox = InboxEntity.Create();
            this.InboxTable.AddObject(inbox);
            await this.InboxTable.SaveChangesWithMergeAsync(inbox);

            string messageReceivingEndpoint = this.GetAbsoluteUrlForAction("Slot", new { id = inbox.RowKey }).AbsoluteUri;
            var result = new InboxCreationResponse
            {
                MessageReceivingEndpoint = messageReceivingEndpoint,
                InboxOwnerCode = inbox.InboxOwnerCode,
            };
            return new JsonResult { Data = result };
        }