Exemplo n.º 1
0
		public void SetUp() {
			AzureStorageConfig.RegisterConfiguration();

			var testContainerName = "unittests" + Guid.NewGuid().ToString();
			var testTableName = "unittests" + Guid.NewGuid().ToString().Replace("-", string.Empty);
			var account = CloudStorageAccount.DevelopmentStorageAccount;
			var client = account.CreateCloudBlobClient();
			this.tableClient = account.CreateCloudTableClient();
			this.tableClient.GetTableReference(testTableName).CreateIfNotExists();
			this.container = client.GetContainerReference(testContainerName);
			this.container.CreateContainerWithPublicBlobsIfNotExistAsync();
			this.controller = new InboxControllerForTest(this.container.Name, testTableName, CloudConfigurationName);
		}
Exemplo n.º 2
0
        private async Task PostNotificationHelper(InboxController controller, Stream inputStream = null, int lifetimeInMinutes = 10)
        {
            SetupNextRequest(controller, "POST", inputStream);

            var result = await controller.PostNotificationAsync(this.inboxId, lifetimeInMinutes);
            Assert.IsType(typeof(HttpStatusCodeResult), result);
            var actualStatus = (HttpStatusCode)((HttpStatusCodeResult)result).StatusCode;
            Assert.Equal(HttpStatusCode.Created, actualStatus);
        }
Exemplo n.º 3
0
        private static void SetupNextRequest(InboxController controller, string httpMethod, Stream inputStream = null, NameValueCollection form = null)
        {
            Requires.NotNull(controller, "controller");
            inputStream = inputStream ?? new MemoryStream(new byte[] { 0x1, 0x3, 0x2 });

            var request = new Mock<HttpRequestBase>();
            request.SetupGet(r => r.InputStream).Returns(inputStream);
            request.SetupGet(r => r.HttpMethod).Returns(httpMethod);
            request.SetupGet(r => r.ContentLength).Returns((int)inputStream.Length);
            request.SetupGet(r => r.Form).Returns(form ?? new NameValueCollection());

            var httpContext = new Mock<HttpContextBase>();
            httpContext.SetupGet(c => c.Request).Returns(request.Object);

            var controllerContext = new Mock<ControllerContext>();
            controllerContext.SetupGet(cc => cc.HttpContext).Returns(httpContext.Object);

            controller.ControllerContext = controllerContext.Object;
        }