コード例 #1
0
        public void can_update_donator_entry()
        {
            var donator = new DonatorBuilder()
                          .With(d => d.Id, 123)
                          .With(d => d.PatreonName, "Jimmybob")
                          .With(d => d.Tier, 1)
                          .With(d => d.ActualDonationAmount, 1)
                          .BuildAndSave();

            var user = new UserBuilder()
                       .With(d => d.Donator, donator)
                       .BuildAndSave();

            var cmd = new UpdateDonator()
            {
                UserId = user.Id,
                ActualDonationAmount = 9,
                PatreonName          = "Jimmybob the second",
                Tier         = 3,
                SpecialNotes = "good boy!"
            };

            Assert.That(() => DomainRegistry.Repository.Execute(cmd), Throws.Nothing);

            Assert.That(DataContext.AsQueryable <Donator>().Where(d =>
                                                                  d.PatreonName == "Jimmybob the second" &&
                                                                  d.ActualDonationAmount == 9 &&
                                                                  d.Tier == 3 &&
                                                                  d.SpecialNotes == "good boy!"), Has.Exactly(1).Items);
        }
コード例 #2
0
        public void should_throw_error_if_user_not_found()
        {
            var cmd = new UpdateDonator
            {
                UserId = "fakeuser",
                ActualDonationAmount = 9,
                PatreonName          = "Bob",
                Tier = 3
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("User 'fakeuser' could not be found"));
        }
コード例 #3
0
        public void should_require_user()
        {
            var cmd = new UpdateDonator
            {
                UserId = null,
                ActualDonationAmount = 9,
                PatreonName          = "Bob",
                Tier = 3
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("userId is required"));
        }
コード例 #4
0
        public virtual ActionResult EditSend(UpdateDonator input)
        {
            input.UserId      = input.UserId.Trim();
            input.PatreonName = input.PatreonName.Trim();
            try
            {
                DomainRegistry.Repository.Execute(input);
                DomainRegistry.Repository.Execute(new ChangeDonatorTier {
                    UserId = input.UserId, Tier = input.Tier
                });
                TempData["Result"] = "Donator update successful.";
            }
            catch (DomainException e)
            {
                TempData["Error"] = "Error: " + e.Message;
            }

            return(RedirectToAction(MVC.Donator.List()));
        }
コード例 #5
0
ファイル: User.cs プロジェクト: transformania/tt-game
 public void UpdateDonator(UpdateDonator cmd)
 {
     this.Donator.Update(cmd.PatreonName, cmd.Tier, cmd.ActualDonationAmount, cmd.SpecialNotes);
 }