예제 #1
0
        public void Execute(CreateMemberModel model)
        {
            var category = _database.Categories
                           .FirstOrDefault(x => x.Id == model.Category.Id);

            var Member = _factory.Create(
                model.Name,
                category,
                model.BirthDate);

            int _Id = (from x in _database.BalanceSheets
                       orderby x.Id descending
                       select x.Id).FirstOrDefault();

            _Id++;

            Domain.BalanceSheet balanceSheet = new Domain.BalanceSheet()
            {
                Id = _Id
            };
            Member.BalanceSheet = balanceSheet;

            _database.Members.Add(Member);

            _database.Save();
        }
예제 #2
0
        public async Task <SimpleResponse <Member> > Handle(SignUpMemberCommand request, CancellationToken cancellationToken)
        {
            var member = _memberFactory.Create(request.Email, request.Name,
                                               request.MonthlyExpense, request.MonthlySalary);

            member = await _memberService.SignUpMember(member);

            await _userUnitOfWork.SaveChangesAsync(cancellationToken);

            member = await _memberService.GetMemberById(member.Id);

            return(SimpleResponse <Member> .Create(member));
        }
예제 #3
0
        public void GivenAccountFactory_WhenCallCreate_ShouldReturnAccount()
        {
            var testData = (Email : "*****@*****.**", Name : "jack", MonthlySalary : 3012, MonthlyExpense : 3013);
            var member   = _memberFactory.Create(testData.Email, testData.Name, testData.MonthlyExpense, testData.MonthlySalary);

            member.ShouldNotBeNull();
            member.ShouldSatisfyAllConditions(
                () => member.Email.ShouldBe(testData.Email),
                () => member.Name.ShouldBe(testData.Name),
                () => member.MemberSalary.Amount.ShouldBe(testData.MonthlySalary),
                () => member.MemberSalary.IsMonthlySalary.ShouldBeTrue(),
                () => member.MemberExpense.Amount.ShouldBe(testData.MonthlyExpense),
                () => member.MemberExpense.IsMonthlyBill.ShouldBeTrue());
        }
예제 #4
0
        public async Task GivenSignUpMemberHandler_WhenCallHandle_IfMemberFound_ShouldSignUpMember()
        {
            // assign
            var query = new SignUpMemberCommand
            {
                Name           = "jack",
                Email          = "*****@*****.**",
                MonthlySalary  = 1000,
                MonthlyExpense = 3000
            };
            var member = MemberDataBuilder.CreateMember(1, null, null, null);

            _memberFactory.Create(query.Email, query.Name, query.MonthlyExpense, query.MonthlySalary).Returns(member);
            _memberService.SignUpMember(Arg.Any <Member>()).Returns(member);
            _memberService.GetMemberById(Arg.Any <long>()).Returns(member);
            // act
            var response = await _signUpMemberHandler.Handle(query, CancellationToken.None);

            // assert
            await _unitOfWork.Received(1).SaveChangesAsync(CancellationToken.None);

            response.ShouldNotBeNull();
            response.Data.ShouldBe(member);
        }