Exemple #1
0
        public async void AuthApi_Login_CallsCorrectUrl()
        {
            // arrange
            var username = _fixture.Create <string>();
            var password = _fixture.Create <string>();
            var otpCode  = _fixture.Create <string>();

            var expectedResponse = new ApiResponse <LoginResponse>
            {
                Success = true,
                Data    = _fixture.Create <LoginResponse>()
            };

            _httpTest.RespondWithJson(expectedResponse);

            // act
            await _authApi.LoginAsync(username, password, otpCode);

            // assert
            _httpTest
            .ShouldHaveCalled($"{_synologyFixture.BaseUrl}/{_apiInfo.Path}*")
            .WithQueryParams(new
            {
                api      = _apiInfo.Name,
                version  = _apiInfo.Version,
                method   = "login",
                account  = username,
                passwd   = password,
                session  = _apiInfo.SessionName,
                format   = "sid",
                otp_code = otpCode
            });
        }