public async Task TestClientCrudOperationsAsync() { var beacon1 = await _client.CreateAsync(null, TestModel.CreateBeacon()); var beacon2 = await _client.CreateAsync(null, TestModel.CreateBeacon()); var page = await _client.GetPageByFilterAsync(null, null, null); Assert.Equal(2, page.Data.Count); await _client.DeleteByIdAsync(null, beacon1.Id); var result = await _client.GetOneByIdAsync(null, beacon1.Id); Assert.Null(result); beacon2.Label = "New Label "; beacon2.Radius = 11.0; result = await _client.UpdateAsync(null, beacon2); TestModel.AssertEqual(beacon2, result); await _client.DeleteByIdAsync(null, beacon2.Id); page = await _client.GetPageByFilterAsync(null, null, null); Assert.Empty(page.Data); }
public async Task TestCreateBeacon() { var beacon = TestModel.CreateBeacon(); var result = await _persistence.CreateAsync(null, beacon); TestModel.AssertEqual(beacon, result); }
public async Task TestGetBeaconByUdi() { var beacon = await _persistence.CreateAsync(null, TestModel.CreateBeacon()); var result = await _persistence.GetOneByIdAsync(null, beacon.Udi); TestModel.AssertEqual(beacon, result); }
public async Task It_Should_Create_Guide() { // arrange var guide = TestModel.CreateGuide(); // act var result = await _client.CreateGuideAsync(null, guide); // assert TestModel.AssertEqual(guide, result); }
public async Task TestUpdateBeacon() { var beacon = await _persistence.CreateAsync(null, TestModel.CreateBeacon()); beacon.Label = "Update Label"; beacon.Type = "Update Type"; var result = await _persistence.UpdateAsync(null, beacon); TestModel.AssertEqual(beacon, result); }
public async Task TestDeleteBeacon() { var beacon = await _persistence.CreateAsync(null, TestModel.CreateBeacon()); var deletedBeacon = await _persistence.DeleteByIdAsync(null, beacon.Id); var result = await _persistence.GetOneByIdAsync(null, beacon.Id); TestModel.AssertEqual(beacon, deletedBeacon); Assert.Null(result); }
public async Task It_Should_Create_Guide() { // arrange var guide = TestModel.CreateGuide(); // act var result = await Invoke <GuideV1>("create_guide", new { guide, paging = _defaultPagingParams, }); // assert TestModel.AssertEqual(guide, result); }
public async Task It_Should_Get_Guide_By_Id() { // arrange var guide = await _client.CreateGuideAsync(null, TestModel.CreateGuide()); // act var result = await _client.GetGuideByIdAsync(null, guide.Id); // assert TestModel.AssertEqual(guide, result); }
public async Task TestGetLimitById() { // arrange var limit = await _persistence.CreateAsync(null, TestModel.CreateLimit1()); // act var result = await _persistence.GetOneByIdAsync(null, limit.Id); // assert TestModel.AssertEqual(limit, result); }
public async Task TestCreateLimit() { // arrange var limit = TestModel.CreateLimit1(); // act var result = await _persistence.CreateAsync(null, limit); // assert TestModel.AssertEqual(limit, result); }
public async Task It_Should_Update_Guide() { // arrange var guide1 = await _client.CreateGuideAsync(null, TestModel.CreateGuide()); // act guide1.Name = RandomText.Word(); var result = await _client.UpdateGuideAsync(null, guide1); // assert Assert.NotNull(result); TestModel.AssertEqual(guide1, result); }
public async void It_Should_Update_Limits_Async() { //arrange var limit = TestModel.CreateLimit1(); //act await _controller.CreateLimitAsync(null, limit); var result = await _controller.UpdateLimitAsync(null, limit); //assert TestModel.AssertEqual(limit, result); }
public async Task It_Should_Get_Guide_By_Id() { // arrange var guide = await Invoke <GuideV1>("create_guide", new { guide = TestModel.CreateGuide(), paging = _defaultPagingParams, }); // act var result = await Invoke <GuideV1>("get_guide_by_id", new { id = guide.Id, paging = _defaultPagingParams, }); // assert TestModel.AssertEqual(guide, result); }
public async Task TestUpdateLimit() { // arrange var limit = await _persistence.CreateAsync(null, TestModel.CreateLimit1()); // act limit.Limit = limit.Limit * 10; var result = await _persistence.UpdateAsync(null, limit); // assert TestModel.AssertEqual(limit, result); }
public async void It_Should_Get_Limit_By_Id_Async() { //arrange var limit = TestModel.CreateLimit1(); //act await _controller.CreateLimitAsync(null, limit); var result = await _controller.GetLimitByIdAsync(null, limit.Id); //assert TestModel.AssertEqual(limit, result); }
public async Task It_Should_Update_Guide() { // arrange var guide = await Invoke <GuideV1>("create_guide", new { guide = TestModel.CreateGuide(), paging = _defaultPagingParams, }); // act guide.Name = RandomText.Word(); var result = await Invoke <GuideV1>("update_guide", new { guide = guide, paging = _defaultPagingParams, }); // assert TestModel.AssertEqual(guide, result); }
public async Task TestDeleteLimit() { // arrange var limit = await _persistence.CreateAsync(null, TestModel.CreateLimit1()); // act var deletedLimit = await _persistence.DeleteByIdAsync(null, limit.Id); var result = await _persistence.GetOneByIdAsync(null, limit.Id); // assert TestModel.AssertEqual(limit, deletedLimit); Assert.Null(result); }
public async Task It_Should_Delete_Guide() { // arrange var guide = await _client.CreateGuideAsync(null, TestModel.CreateGuide()); // act var deletedGuide = await _client.DeleteGuideByIdAsync(null, guide.Id); var result = await _client.GetGuideByIdAsync(null, guide.Id); // assert TestModel.AssertEqual(guide, deletedGuide); Assert.Null(result); }
public async void It_Should_Increase_Limit() { //arrange var limit = TestModel.CreateLimit1(); await _controller.CreateLimitAsync(null, limit); //act var amount = (long)(limit.Limit * 0.1); var result = await _controller.IncreaseLimitOfUserAsync(null, limit.UserId, amount); limit.Limit += amount; //assert TestModel.AssertEqual(limit, result); }
public async void It_Should_Decrease_Amount_Used() { //arrange var limit = TestModel.CreateLimit1(); await _controller.CreateLimitAsync(null, limit); //act var amount = (long)(limit.AmountUsed * 0.5); var result = await _controller.DecreaseAmountUsedByUserAsync(null, limit.UserId, amount); limit.AmountUsed -= amount; //assert TestModel.AssertEqual(limit, result); }
public async void It_Should_Not_Decrease_Amount_Used_Below_Zero() { //arrange var limit = TestModel.CreateLimit1(); await _controller.CreateLimitAsync(null, limit); //act var result1 = await _controller.DecreaseAmountUsedByUserAsync(null, limit.UserId, limit.AmountUsed); limit.AmountUsed = 0; var result2 = await _controller.DecreaseAmountUsedByUserAsync(null, limit.UserId, 1); //assert TestModel.AssertEqual(limit, result1); Assert.Null(result2); }
public async Task TestGetBeaconsByFilter() { var beacon1 = await _persistence.CreateAsync(null, TestModel.CreateBeacon()); var beacon2 = await _persistence.CreateAsync(null, TestModel.CreateBeacon()); var filter = FilterParams.FromTuples( "site_id", $"{String.Join(",", beacon2.SiteId)}", "udi", beacon1.Udi ); var result = await _persistence.GetPageByFilterAsync(null, filter, null); Assert.NotNull(result); Assert.Equal(2, result.Data.Count); TestModel.AssertEqual(beacon1, result.Data[0]); }
public async void It_Should_Increase_Amount_Used() { //arrange var limit = TestModel.CreateLimit1(); //CurrentAmountUsed = 5000, //Limit = 100000 await _controller.CreateLimitAsync(null, limit); //act var amount = (long)(limit.Limit * 0.1); var result = await _controller.IncreaseAmountUsedByUserAsync(null, limit.UserId, amount); limit.AmountUsed += amount; //assert TestModel.AssertEqual(limit, result); }
//This part is pretty much identical to LimitsPersistenceFixute private async Task TestCreateLimits() { // arrange var limit1 = TestModel.CreateLimit1(); var limit2 = TestModel.CreateLimit2(); var limit3 = TestModel.CreateLimit3(); // act var result1 = await _client.CreateLimitAsync(null, limit1); var result2 = await _client.CreateLimitAsync(null, limit2); var result3 = await _client.CreateLimitAsync(null, limit3); // assert TestModel.AssertEqual(limit1, result1); TestModel.AssertEqual(limit2, result2); TestModel.AssertEqual(limit3, result3); }
public async void It_Should_Create_Limits_Async() { //arrange var limit1 = TestModel.CreateLimit1(); var limit2 = TestModel.CreateLimit2(); var limit3 = TestModel.CreateLimit3(); //act var result1 = await _controller.CreateLimitAsync(null, limit1); var result2 = await _controller.CreateLimitAsync(null, limit2); var result3 = await _controller.CreateLimitAsync(null, limit3); //assert TestModel.AssertEqual(limit1, result1); TestModel.AssertEqual(limit2, result2); TestModel.AssertEqual(limit3, result3); }
public async Task It_Should_Test_Crud_Operations() { var expectedBeacon1 = TestModel.CreateBeacon(); var beacon1 = await Invoke <BeaconV1>("create_beacon", new { beacon = expectedBeacon1 }); TestModel.AssertEqual(expectedBeacon1, beacon1); var expectedBeacon2 = TestModel.CreateBeacon(); var beacon2 = await Invoke <BeaconV1>("create_beacon", new { beacon = expectedBeacon1 }); TestModel.AssertEqual(expectedBeacon1, beacon2); var page = await Invoke <DataPage <BeaconV1> >("get_beacons", new { }); Assert.NotNull(page); Assert.Equal(2, page.Data.Count); beacon1.Radius = 25.0; beacon2.Radius = 50.0; var beacon = await Invoke <BeaconV1>("update_beacon", new { task = beacon1 }); TestModel.AssertEqual(beacon1, beacon); beacon = await Invoke <BeaconV1>("delete_beacon", new { id = beacon1.Id }); Assert.NotNull(beacon); Assert.Equal(beacon1.Id, beacon.Id); beacon = await Invoke <BeaconV1>("get_beacon", new { id = beacon1.Id }); Assert.Null(beacon); beacon = await Invoke <BeaconV1>("delete_beacon", new { id = beacon2.Id }); Assert.NotNull(beacon); Assert.Equal(beacon2.Id, beacon.Id); }
public async Task It_Should_Do_All_Operations() { LimitV1 expectedLimit1 = TestModel.CreateLimit1(); LimitV1 limit1 = await Invoke <LimitV1>("create_limit", new { limit = expectedLimit1 }); TestModel.AssertEqual(expectedLimit1, limit1); var expectedLimit2 = TestModel.CreateLimit2(); var limit2 = await Invoke <LimitV1>("create_limit", new { limit = expectedLimit2 }); TestModel.AssertEqual(expectedLimit2, limit2); var expectedLimit3 = TestModel.CreateLimit3(); var limit3 = await Invoke <LimitV1>("create_limit", new { limit = expectedLimit3 }); TestModel.AssertEqual(expectedLimit3, limit3); var page = await Invoke <DataPage <LimitV1> >("get_limits", new { }); Assert.NotNull(page); Assert.Equal(3, page.Data.Count); limit1.AmountUsed = limit1.Limit / 2; var limit = await Invoke <LimitV1>("update_limit", new { limit = limit1 }); TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("get_limit_by_id", new { id = limit1.Id }); TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("get_limit_by_user_id", new { user_id = limit1.UserId }); TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("decrease_limit_of_user", new { decrease_by = limit1.Limit / 2, user_id = limit1.UserId }); limit1.Limit -= limit1.Limit / 2; TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("increase_limit_of_user", new { increase_by = limit1.Limit / 2, user_id = limit1.UserId }); limit1.Limit += limit1.Limit / 2; TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("decrease_amount_used_by_user", new { decrease_by = limit1.AmountUsed / 2, user_id = limit1.UserId }); limit1.AmountUsed -= limit1.AmountUsed / 2; TestModel.AssertEqual(limit1, limit); limit = await Invoke <LimitV1>("increase_amount_used_by_user", new { increase_by = limit1.AmountUsed / 2, user_id = limit1.UserId }); limit1.AmountUsed += limit1.AmountUsed / 2; TestModel.AssertEqual(limit1, limit); var amountAvailable = await Invoke <ResultV1>("get_amount_available_to_user", new { user_id = limit1.UserId }); Assert.Equal(amountAvailable.longResult, limit1.Limit - limit1.AmountUsed); var isIncreasable = await Invoke <ResultV1>("can_user_add_amount", new { user_id = limit1.UserId, amount = limit1.Limit }); Assert.False(isIncreasable.boolResult); isIncreasable = await Invoke <ResultV1>("can_user_add_amount", new { user_id = limit1.UserId, amount = amountAvailable.longResult }); Assert.True(isIncreasable.boolResult); //Delete all limit = await Invoke <LimitV1>("delete_limit_by_id", new { id = limit1.Id }); Assert.NotNull(limit); Assert.Equal(limit1.Id, limit.Id); limit = await Invoke <LimitV1>("get_limit_by_id", new { id = limit1.Id }); Assert.Null(limit); limit = await Invoke <LimitV1>("delete_limit_by_id", new { id = limit2.Id }); Assert.NotNull(limit); Assert.Equal(limit2.Id, limit.Id); limit = await Invoke <LimitV1>("get_limit_by_id", new { id = limit2.Id }); Assert.Null(limit); limit = await Invoke <LimitV1>("delete_limit_by_id", new { id = limit3.Id }); Assert.NotNull(limit); Assert.Equal(limit3.Id, limit.Id); limit = await Invoke <LimitV1>("get_limit_by_id", new { id = limit3.Id }); Assert.Null(limit); }
public async Task TestAllOperations() { // arrange await TestCreateLimits(); var page = await _client.GetLimitsAsync(null, new FilterParams(), new PagingParams()); var limit1 = page.Data[0]; var limit2 = page.Data[1]; // act limit1.Limit = (long)(limit1.Limit * 1.5); var result1 = await _client.UpdateLimitAsync(null, limit1); // assert TestModel.AssertEqual(limit1, result1); // act var result2 = await _client.GetLimitByUserIdAsync(null, limit1.UserId); // assert TestModel.AssertEqual(limit1, result2); // act var idFilter = await _client.GetLimitsAsync(null, FilterParams.FromTuples("id", "1"), new PagingParams()); var userIdFilter = await _client.GetLimitsAsync(null, FilterParams.FromTuples("user_id", "00002"), new PagingParams()); var idsFilter = await _client.GetLimitsAsync(null, FilterParams.FromTuples("ids", "1,2"), new PagingParams()); var userIdsFilter = await _client.GetLimitsAsync(null, FilterParams.FromTuples("user_ids", "00002,00003"), new PagingParams()); // assert Assert.Equal(1, idFilter.Data.Count); Assert.Equal(1, userIdFilter.Data.Count); Assert.Equal(2, idsFilter.Data.Count); Assert.Equal(2, userIdsFilter.Data.Count); // act var result = await _client.IncreaseLimitOfUserAsync(null, limit2.UserId, (long)(limit2.Limit * 0.5)); limit2.Limit += (long)(limit2.Limit * 0.5); // assert Assert.Equal(limit2.Limit, result.Limit); // act result = await _client.DecreaseLimitOfUserAsync(null, limit2.UserId, (long)(limit2.Limit * 0.5)); limit2.Limit -= (long)(limit2.Limit * 0.5); // assert TestModel.AssertEqual(limit2, result); // act result = await _client.IncreaseAmountUsedByUserAsync(null, limit2.UserId, limit2.AmountUsed); limit2.AmountUsed *= 2; // assert TestModel.AssertEqual(limit2, result); // act result = await _client.DecreaseAmountUsedByUserAsync(null, limit2.UserId, limit2.AmountUsed / 2); limit2.AmountUsed /= 2; // assert TestModel.AssertEqual(limit2, result); // act var amountAvailable = (await _client.GetAmountAvailableToUserAsync(null, limit2.UserId)); // assert Assert.Equal(amountAvailable.longResult, limit2.Limit - limit2.AmountUsed); // act var trueResult = await _client.CanUserAddAmountAsync(null, limit2.UserId, amountAvailable.longResult); var falseResult = await _client.CanUserAddAmountAsync(null, limit2.UserId, amountAvailable.longResult + 1); // assert Assert.True(trueResult.boolResult); Assert.False(falseResult.boolResult); // act var result3 = await _client.DeleteLimitByIdAsync(null, limit1.Id); var result4 = await _client.GetLimitByIdAsync(null, limit1.Id); // assert TestModel.AssertEqual(limit1, result3); Assert.Null(result4); }