public async Task when_creating_an_item_with_an_other_user_createItem_service_should_navigate_to_the_users_points() { InitializeHttpCallNewItem(OtherUserId); MockAuthorizationForStartechsWhichUserIsLeader(); var target = CreateComponent(OtherUserId); var userId = (int)OtherUserId.Value; await Task.Delay(30); target.Instance.Item.Startech = Startechs.Agile; MockHttp.Expect(HttpMethod.Post, $"http://localhost/StarpointsManager/CreateStarpoints/{userId}").Respond(HttpStatusCode.OK); MockGetThisUserHttpRequest(33); await target.Instance.UpdateOrCreate(); HasNavigatedToUrl.Should().Be($"/Points/{userId}"); }
public async Task when_updating_an_item_with_an_other_user_updateItem_service_should_be_called_with_the_user_id() { const int userId = 17; InitializeHttpCallUpdateItem(11, userId); MockAuthorizationForStartechsWhichUserIsLeader(); var target = CreateComponent(TestItemId); await Task.Delay(30); target.Instance.Item.Startech = Startechs.Agile; MockHttp.Expect(HttpMethod.Post, $"http://localhost/StarpointsManager/UpdateStarpoints/{userId}").Respond(HttpStatusCode.OK); MockGetThisUserHttpRequest(userId); await target.Instance.UpdateOrCreate(); MockHttp.VerifyNoOutstandingExpectation(); }
public async Task when_updating_an_item_with_an_other_user_updateItem_service_should_navigate_to_the_users_points() { const int userId = 17; InitializeHttpCallUpdateItem(11, userId); MockAuthorizationForStartechsWhichUserIsLeader(); var target = CreateComponent(TestItemId); await Task.Delay(30); target.Instance.Item.Startech = Startechs.Agile; MockHttp.Expect(HttpMethod.Post, $"http://localhost/StarpointsManager/UpdateStarpoints/{userId}").Respond(HttpStatusCode.OK); MockGetThisUserHttpRequest(11); await target.Instance.UpdateOrCreate(); Console.WriteLine(target.Instance.User.Id); HasNavigatedToUrl.Should().Be($"/Points/{userId}"); }
public async Task when_updating_status_the_update_status_api_method_should_be_called() { ConfirmDisplayer.Setup(x => x.Confirm(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.Factory.StartNew(() => true)); var removeItemEventCallBack = EventCallbackFactory.Create <StarpointsItem>(new object(), _ => { }); var starpointsItem = CreateStarpointsItem(); MockHttp.Expect($"http://localhost/StarpointsManager/CancelStarpoints/-1/{starpointsItem.Id}").Respond(HttpStatusCode.OK); Authorize(starpointsItem, false); var component = CreateComponent(ComponentParameter.CreateParameter("Item", starpointsItem) , ComponentParameter.CreateParameter("PleaseRemoveItem", removeItemEventCallBack)); component.WaitForState(() => component.Nodes?.Length > 0); await component.Instance.CancelItem(); await Task.Delay(30); MockHttp.VerifyNoOutstandingExpectation(); }
private void InitializeHttpCallNewItem(ComponentParameter userIdParameter) { int userId = (int)userIdParameter.Value; MockHttp.Expect(HttpMethod.Get, $"http://localhost/User/GetUser/{userId}") .RespondValues(new UserObject { Id = userId == ThisUser.Id ? ThisUserDatabaseId : userId, UserName = "******" }); MockHttp.Expect(HttpMethod.Get, "http://localhost/StarpointsManager/GetStarpointsType/-1") .RespondValues(new[] { new StarpointsType { Id = 1 } }); if (userId != ThisUser.Id) { MockHttp.Expect(HttpMethod.Get, $"http://localhost/User/GetUserStartechs/{userId}") .RespondValues(new[] { Startechs.Dotnet }); } }
public async Task when_suppressing_item_if_the_pop_up_retrieve_yes_the_item_should_be_suppressed() { ConfirmDisplayer.Setup(x => x.Confirm(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.Factory.StartNew(() => true)); bool hasCallRemoveCallback = false; var removeItemEventCallBack = EventCallbackFactory.Create <StarpointsItem>(new object(), _ => hasCallRemoveCallback = true); var starpointsItem = CreateStarpointsItem(); MockHttp.Expect($"http://localhost/StarpointsManager/CancelStarpoints/-1/{starpointsItem.Id}").Respond(HttpStatusCode.OK); Authorize(starpointsItem, false); var component = CreateComponent(ComponentParameter.CreateParameter("Item", starpointsItem) , ComponentParameter.CreateParameter("PleaseRemoveItem", removeItemEventCallBack)); component.WaitForState(() => component.Nodes?.Length > 0); await component.Instance.CancelItem(); await Task.Delay(30); hasCallRemoveCallback.Should().BeTrue(); }
public async Task when_adding_a_user_the_user_should_be_added() { var userObjectToAdd = new UserObject { Id = 12, UserName = "******" }; MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/GetMembers") .RespondValues(new object [0]); var target = CreateComponent(StartechType); await Task.Delay(30); MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/SetMember/12") .Respond(HttpStatusCode.OK); MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/GetMembers") .RespondValues(new[] { userObjectToAdd }); await target.Instance.Add(userObjectToAdd); MockHttp.VerifyNoOutstandingExpectation(); }
public async Task when_adding_a_user_the_members_should_be_reload() { var userObjectToAdd = new UserObject { Id = 12, UserName = "******" }; MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/GetMembers") .RespondValues(new object[0]); var target = CreateComponent(StartechType); await Task.Delay(30); MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/SetMember/12") .Respond(HttpStatusCode.OK); MockHttp.Expect(HttpMethod.Get, "http://localhost/AdminMember/Dotnet/GetMembers") .RespondValues(new[] { userObjectToAdd }); await target.Instance.Add(userObjectToAdd); target.WaitForAssertion(() => target.Nodes.Any(x => x.NodeValue?.Contains("dotnet_Member") ?? false)); }