public async Task Given_An_ArchetypeCardMessage_If_Archetype_Is_Not_Found_Should_Invoke_Update_Method()
        {
            // Arrange
            var archetypeCardMessage = new ArchetypeCardMessage
            {
                ArchetypeName = "Blue-Eyes White Dragon"
            };

            // Act
            await _sut.Process(archetypeCardMessage);

            // Assert
            await _archetypeCardsService.DidNotReceive().Update(Arg.Any <long>(), Arg.Any <IEnumerable <string> >());
        }
Пример #2
0
        public async Task <ArchetypeDataTaskResult <ArchetypeCardMessage> > Process(ArchetypeCardMessage archetypeData)
        {
            var articleDataTaskResult = new ArchetypeDataTaskResult <ArchetypeCardMessage>
            {
                ArchetypeData = archetypeData
            };

            var existingArchetype = await _archetypeService.ArchetypeByName(archetypeData.ArchetypeName);

            if (existingArchetype != null && archetypeData.Cards.Any())
            {
                await _archetypeCardsService.Update(existingArchetype.Id, archetypeData.Cards);
            }

            return(articleDataTaskResult);
        }
        public async Task Given_An_ArchetypeCardMessage_Should_Always_Invoke_ArchetypeByName_Method_Once()
        {
            // Arrange
            var archetypeCardMessage = new ArchetypeCardMessage
            {
                ArchetypeName = "Blue-Eyes White Dragon"
            };

            _archetypeService.ArchetypeByName(Arg.Any <string>()).Returns(new Archetype());

            // Act
            await _sut.Process(archetypeCardMessage);

            // Assert
            await _archetypeService.Received(1).ArchetypeByName(Arg.Any <string>());
        }
        public async Task Given_An_ArchetypeCardMessage_If_Archetype_Is_Found_Should_Invoke_Update_Method_Once()
        {
            // Arrange
            var archetypeCardMessage = new ArchetypeCardMessage
            {
                ArchetypeName = "Blue-Eyes White Dragon",
                Cards         = new List <string> {
                    "Blue-Eyes White Dragon"
                }
            };

            _archetypeService.ArchetypeByName(Arg.Any <string>()).Returns(new Archetype());

            // Act
            await _sut.Process(archetypeCardMessage);

            // Assert
            await _archetypeCardsService.Received(1).Update(Arg.Any <long>(), Arg.Any <IEnumerable <string> >());
        }