public async void Account_PurgeUrl_invalidUrl(string url) { // Arrange Account account = getValidAccount(); // Act & Assert BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await account.PurgeUrl(url); }); Assert.Equal("Invalid url provided.", exception.Message); }
public async void Account_DeleteStorageZone_invalid(long zoneId) { // Arrange MockHttpMessageHandler mockHttp = MockTools.GetNewMockHandler(); mockHttp.When(HttpMethod.Delete, "*/storagezone/*").Respond(HttpStatusCode.OK); AccountKey accKey = new AccountKey(); accKey.SetToken("17989543-2154-6867-3566-71474693165007735103-0594-4591-2132-259238857481", mockHttp); Account account = new Account(accKey); // Act & Assert BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await account.DeleteStorageZone(zoneId); }); Assert.Equal("Zone Id must be higher than 0.", exception.Message); }
public async void Account_CreateStorageZone_invalid(string zoneName) { // Arrange MockHttpMessageHandler mockHttp = MockTools.GetNewMockHandler(); mockHttp.When(HttpMethod.Post, "*/storagezone").Respond(HttpStatusCode.OK); AccountKey accKey = new AccountKey(); accKey.SetToken("17989543-2154-6867-3566-71474693165007735103-0594-4591-2132-259238857481", mockHttp); Account account = new Account(accKey); // Act & Assert BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await account.CreateStorageZone(zoneName); }); Assert.Equal("Name may only contain alphabetical letters, numbers and dashes with a length of 3-20 characters.", exception.Message); }
public async void Account_ApplyCoupon_invalidInput(string couponCode) { // Arrange MockHttpMessageHandler mockHttp = MockTools.GetNewMockHandler(); mockHttp.When(HttpMethod.Get, "*/billing/applycode").Respond(HttpStatusCode.OK); AccountKey accKey = new AccountKey(); accKey.SetToken("17989543-2154-6867-3566-71474693165007735103-0594-4591-2132-259238857481", mockHttp); Account account = new Account(accKey); // Act & Assert BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await account.ApplyCoupon(couponCode); }); Assert.Equal("The presented coupon cannot be empty/null", exception.Message); }
public async void Account_GetStatisticSummary_badrequest_date_one_invalid(DateTime dtFrom, DateTime dtTo) { // Arrange MockHttpMessageHandler mockHttp = MockTools.GetNewMockHandler(); mockHttp.When(HttpMethod.Get, "*/statistics").Respond(HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(CorrectStatisticSummary)); AccountKey accKey = new AccountKey(); accKey.SetToken("17989543-2154-6867-3566-71474693165007735103-0594-4591-2132-259238857481", mockHttp); Account account = new Account(accKey); // Act & Assert BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await account.GetStatisticSummary(dtFrom, dtTo); }); Assert.Equal("Both 'from' and 'to' dates must be provided", exception.Message); }
public async void Storage_GetFolder_badrequest_invalidResponse(string path) { BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await storage.GetFolder(path); }); Assert.Equal("Invalid response error provided.", exception.Message); }
public async void Storage_GetFolder_badrequest() { BunnyBadRequestException exception = await Assert.ThrowsAsync <BunnyBadRequestException>(async() => { await storage.GetFolder("throwbadrequest"); }); Assert.Equal(MockTools.BadRequestError.Message, exception.Message); }