Esempio n. 1
0
        public void VoiceNoteChoiceRepository_Caches_VoiceNoteChoices()
        {
            // arrange
            var mockVoiceNoteChoiceGenerator       = Substitute.For <IVoiceNoteChoiceGenerator>();
            var mockVoiceNoteChoice                = new VoiceNoteChoice(Voice.Bass, NoteMotion.Ascending, 1);
            var mockVoiceNoteChoiceGeneratorReturn = new HashSet <VoiceNoteChoice> {
                mockVoiceNoteChoice
            };

            mockVoiceNoteChoiceGenerator
            .GenerateVoiceNoteChoices(Arg.Any <Voice>())
            .Returns(mockVoiceNoteChoiceGeneratorReturn);

            var voiceNoteChoiceRepository = new VoiceNoteChoiceRepository(mockVoiceNoteChoiceGenerator);

            foreach (var voice in EnumUtils <Voice> .AsEnumerable())
            {
                // act
                var nonCachedVoiceNoteChoices = voiceNoteChoiceRepository.GetVoiceNoteChoices(voice);
                var cachedVoiceNoteChoices    = voiceNoteChoiceRepository.GetVoiceNoteChoices(voice);

                // assert
                nonCachedVoiceNoteChoices.Should().NotBeEmpty();
                cachedVoiceNoteChoices.Should().NotBeEmpty();

                nonCachedVoiceNoteChoices.Should().BeSameAs(cachedVoiceNoteChoices);

                mockVoiceNoteChoiceGenerator.Received(1).GenerateVoiceNoteChoices(voice);
            }
        }
        public VoiceNoteChoiceRepository(IVoiceNoteChoiceGenerator voiceNoteChoiceGenerator)
        {
            _voiceNoteChoiceGenerator = voiceNoteChoiceGenerator;

            foreach (var voice in EnumUtils <Voice> .AsEnumerable())
            {
                _voiceNoteChoicesByVoice.Add(voice, new HashSet <VoiceNoteChoice>());
            }
        }
Esempio n. 3
0
        public void VoiceNoteChoiceGenerator_Only_Generates_List_Of_Unique_Voice_Note_Choices()
        {
            var voiceNoteChoiceGenerator = new VoiceNoteChoiceGenerator();

            foreach (var voice in EnumUtils <Voice> .AsEnumerable())
            {
                var voiceNoteChoices = voiceNoteChoiceGenerator.GenerateVoiceNoteChoices(voice);

                voiceNoteChoices.Should().OnlyHaveUniqueItems();
            }
        }
        public void SetUp()
        {
            _mockVoiceNoteChoiceRepository = Substitute.For <IVoiceNoteChoiceRepository>();

            foreach (var voice in EnumUtils <Voice> .AsEnumerable())
            {
                _mockVoiceNoteChoiceRepository
                .GetVoiceNoteChoices(voice)
                .Returns(MockVoiceNoteChoicesByVoice[voice]);
            }
        }
Esempio n. 5
0
        public void AsEnumerable_Generates_Expected_Enumerable_With_NonEmpty_Enum()
        {
            var expectedEnumerable = new[]
            {
                Weekday.Monday,
                Weekday.Tuesday,
                Weekday.Wednesday,
                Weekday.Thursday,
                Weekday.Friday
            };

            var enumerable = EnumUtils<Weekday>.AsEnumerable();

            enumerable.Should().BeEquivalentTo(expectedEnumerable);
        }
Esempio n. 6
0
        public void AsEnumerable_Generates_Expected_Enumerable_With_Empty_Enum()
        {
            var enumerable = EnumUtils<Friends>.AsEnumerable();

            enumerable.Should().BeEmpty();
        }