Beispiel #1
0
        public void LoadRandom()
        {
            var fullName = NPCBuilder.GetRandomName();

            firstName = fullName.Split(' ')[0];
            name      = fullName.Split(' ')[1];
        }
        public void Should_have_NPC()
        {
            var npc = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            cmd.NPCId = npc.Id;

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

            Assert.That(DataContext.AsQueryable <Player>().Where(p =>
                                                                 p.NPC.Id == npc.Id), Has.Exactly(1).Items);
        }
Beispiel #3
0
        public void Should_create_new_RestockItem()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 195).BuildAndSave();
            var npc  = new NPCBuilder().With(ri => ri.Id, 4).BuildAndSave();

            var cmd = new CreateRestockItem {
                AmountBeforeRestock = 0, BaseItemId = item.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(Repository.Execute(cmd), Is.GreaterThan(0));
        }
Beispiel #4
0
        public void Should_throw_error_when_no_restock_item_id()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            var cmd = new UpdateRestockItem {
                AmountBeforeRestock = 1, BaseItemId = item.Id, AmountToRestockTo = 1, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("RestockItemId must be set"));
        }
Beispiel #5
0
        public void Should_not_throw_error_when_amount_to_restock_is_zero()
        {
            var amount = 0;

            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            var cmd = new CreateRestockItem {
                AmountBeforeRestock = amount, BaseItemId = item.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(Repository.Execute(cmd), Is.GreaterThan(0));
        }
Beispiel #6
0
        public void Should_throw_error_when_invalid_amount_to_restockTo()
        {
            var amount = 0;

            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            var cmd = new CreateRestockItem {
                AmountBeforeRestock = 1, BaseItemId = item.Id, AmountToRestockTo = amount, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("Minimum amount to restock to must be 1"));
        }
Beispiel #7
0
        public void Should_find_player_by_id()
        {
            var user = new UserBuilder().With(u => u.Id, "guid").BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();
            var form = new FormSourceBuilder().With(n => n.Id, 101).BuildAndSave();

            new PlayerBuilder()
            .With(p => p.Id, 23)
            .With(p => p.User, user)
            .With(p => p.NPC, npc)
            .With(p => p.FormSource, form)
            .BuildAndSave();

            var cmd = new GetPlayer {
                PlayerId = 23
            };

            var foundPlayer = DomainRegistry.Repository.FindSingle(cmd);

            Assert.That(foundPlayer.Id, Is.EqualTo(23));
            Assert.That(foundPlayer.NPC.Id, Is.EqualTo(7));
            Assert.That(foundPlayer.FormSource.Id, Is.EqualTo(101));
        }