Пример #1
0
        private async Task CreateProfileTestRunnerAsync(IUserProfileServices creator, string input, bool isValidParse, bool isValidAccount, bool isExistingAccount, int serverTimeOut, int clientTimeOut) {
            ManualResetEventSlim testDone = new ManualResetEventSlim(false);
            Task.Run(async () => {
                try {
                    if (isValidParse) {
                        Func<Task> f = async () => await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator);
                        f.ShouldNotThrow();
                    } else {
                        Func<Task> f = () => RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator);
                        await f.ShouldThrowAsync<Exception>();
                    }
                } finally {
                    testDone.Set();
                }
            }).DoNotWait();

            using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                UserProfileResultMock result = await CreateProfileClientTestWorkerAsync(input, cts.Token);
                if (isValidParse) {
                    result.Error.Should().Be((uint)(isValidAccount ? 0 : 13));
                    result.ProfileExists.Should().Be(isExistingAccount);
                } else {
                    result.Should().BeNull();
                }
            }

            testDone.Wait(serverTimeOut + clientTimeOut);
        }
 public UserProfileController(IUserProfileServices userProfileServices,
                              ISmsServices smsServices,
                              IAuthenticationService <int> authService,
                              ILogger <IUserProfileServices> logger) : base(logger)
 {
     _userProfileServices = userProfileServices;
     _authService         = authService;
     _smsServices         = smsServices;
 }
Пример #3
0
 public UserController(ICloudinaryServices cloudinaryService,
                       IUserProfileServices userProfileServices,
                       IMapper mapper,
                       SignInManager <User> signInManager)
 {
     this.cloudinaryService   = cloudinaryService;
     this.userProfileServices = userProfileServices;
     this.mapper        = mapper;
     this.signInManager = signInManager;
 }
Пример #4
0
 public AccountController(
     IMapper mapper,
     ICloudinaryServices cloudinary,
     IUserProfileServices userProfileServices,
     SignInManager <User> signInManager)
 {
     this.mapper              = mapper;
     this.cloudinary          = cloudinary;
     this.userProfileServices = userProfileServices;
     this.signInManager       = signInManager;
 }
Пример #5
0
        private async Task CreateProfileFuzzTestRunnerAsync(IUserProfileServices creator, string input, int serverTimeOut, int clientTimeOut) {
            var task = Task.Run(async () => {
                try {
                    await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator);
                } catch (JsonReaderException) {
                    // expecting JSON parsing to fail
                    // JSON parsing may fail due to randomly generated strings as input.
                }
            });

            using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                UserProfileResultMock result = await CreateProfileClientTestWorkerAsync(input, cts.Token);
                // fuzz test parsing succeeded, the creator always fails for this test.
                result?.Error.Should().Be(13);
            }

            await ParallelTools.When(task, serverTimeOut + clientTimeOut);
        }
        private async Task CreateProfileFuzzTestRunnerAsync(IUserProfileServices creator, IUserProfileNamedPipeFactory pipeFactory, string input, int serverTimeOut, int clientTimeOut)
        {
            var task = Task.Run(async() => {
                try {
                    await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                } catch (JsonReaderException) {
                    // expecting JSON parsing to fail
                    // JSON parsing may fail due to randomly generated strings as input.
                }
            });

            using (var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                var result = await CreateProfileClientTestWorkerAsync(input, cts.Token);

                // fuzz test parsing succeeded, the creator always fails for this test.
                result?.Error.Should().Be(13);
            }

            await ParallelTools.When(task, serverTimeOut + clientTimeOut);
        }
        public UserProfileValidator(IUserProfileServices userAccountService)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;
            RuleSet("AddProfile", () =>
            {
                RuleFor(x => x.Email).NotEmpty().EmailAddress();
            });

            RuleSet("UpdateProfile", () =>
            {
                //   RuleFor(x => x.Id).MustAsync(async (id, token) =>
                //(await userAccountService.ExistsAsync(id).ConfigureAwait(false)));
            });

            RuleFor(x => x.FirstName).NotEmpty().Length(1, 105);
            RuleFor(x => x.LastName).NotEmpty().Length(1, 105);
            RuleFor(x => x.Email).NotEmpty().EmailAddress();
            RuleFor(x => x.DateOfBirth).NotEmpty();
            RuleFor(x => x.Subscription).NotEmpty();
            RuleFor(x => x.SearchCriteria.MinDiscount).GreaterThanOrEqualTo(0).WithMessage("Dicount must be greater or equal than 0");
            RuleFor(x => x.SearchCriteria.MaxDiscount).LessThan(100).GreaterThanOrEqualTo(0).WithMessage("Dicount must be less than 100");
        }
        private async Task CreateProfileTestRunnerAsync(IUserProfileServices creator, IUserProfileNamedPipeFactory pipeFactory, string input, bool isValidParse, bool isValidAccount, bool isExistingAccount, int serverTimeOut, int clientTimeOut)
        {
            var testDone = new ManualResetEventSlim(false);

            Task.Run(async() => {
                try {
                    if (isValidParse)
                    {
                        Func <Task> f = async() => await RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                        f.ShouldNotThrow();
                    }
                    else
                    {
                        Func <Task> f = () => RUserProfileServicesHelper.CreateProfileAsync(serverTimeOutms: serverTimeOut, clientTimeOutms: clientTimeOut, userProfileService: creator, pipeFactory: pipeFactory);
                        await f.ShouldThrowAsync <Exception>();
                    }
                } finally {
                    testDone.Set();
                }
            }).DoNotWait();

            using (var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(clientTimeOut))) {
                var result = await CreateProfileClientTestWorkerAsync(input, cts.Token);

                if (isValidParse)
                {
                    result.Error.Should().Be((uint)(isValidAccount ? 0 : 13));
                    result.ProfileExists.Should().Be(isExistingAccount);
                }
                else
                {
                    result.Should().BeNull();
                }
            }

            testDone.Wait(serverTimeOut + clientTimeOut);
        }
Пример #9
0
 public static async Task DeleteProfileAsync(int serverTimeOutms = 0, int clientTimeOutms = 0, IUserProfileServices userProfileService = null, CancellationToken ct = default(CancellationToken), ILogger logger = null) {
     userProfileService = userProfileService ?? new RUserProfileServices();
     await ProfileServiceOperationAsync(userProfileService.DeleteUserProfile, NamedPipeServerStreamFactory.DeletorName, serverTimeOutms, clientTimeOutms, ct, logger);
 }
Пример #10
0
 public ValuesController(IUserProfileServices userProfileServices)
 {
     _userProfileServices = userProfileServices;
 }
 public UserProfileController(IUserProfileServices userServices)
 {
     this.userServices = userServices;
 }
Пример #12
0
 public RequestChatHub(IUserProfileServices userProfileService,
                       IRequestChatServices service)
 {
     this.userProfileService = userProfileService;
     this.service            = service;
 }
 public ConversationsController()
 {
     _userProfileServices = new UserProfileServices();
 }
Пример #14
0
 public static async Task DeleteProfileAsync(int serverTimeOutms = 0, int clientTimeOutms = 0, IUserProfileServices userProfileService = null, IUserProfileNamedPipeFactory pipeFactory = null, CancellationToken ct = default(CancellationToken), ILogger logger = null)
 {
     userProfileService = userProfileService ?? new RUserProfileServices();
     pipeFactory        = pipeFactory ?? new NamedPipeServerStreamFactory();
     await ProfileServiceOperationAsync(userProfileService.DeleteUserProfile, NamedPipeServerStreamFactory.DeletorName, pipeFactory, serverTimeOutms, clientTimeOutms, ct, logger);
 }
 public UserProfileController(IUserProfileServices userProfileService)
 {
     this._userProfileService = userProfileService;
 }
Пример #16
0
 public UserProfileController(IUserProfileServices userProfileServices)
 {
     _userProfileServices = userProfileServices;
 }