Exemplo n.º 1
0
        public async Task ShouldInvokeJsLocalStorageSetWithAppropriateDataOnChangeCurrentCulture()
        {
            string cultureName = "fake-CL";

            await _localStorageService.Handle(new ChangeCurrentCultureMessage(cultureName), CancellationToken.None);

            _jsRuntimeMock.Invocations.Count.Should().Be(2);
            var jsInvocations = _jsRuntimeMock.Invocations.ToArray();

            jsInvocations[0].Identifier.Should().Be("localStorage.getItem");
            jsInvocations[1].Identifier.Should().Be("localStorage.setItem");

            var args = jsInvocations[1].Arguments;

            args.Should().NotBeNull();
            args.Count.Should().Be(2);
            args[0].Should().Be("user-settings");
            args[1].Should().Be($"{{\"Culture\":\"{cultureName}\"}}");

            _navigationManagerMock.NavigationCount.Should().Be(1);
        }