public void TestGetFormatWorksOnExistingFormat()
        {
            Mock <IFormatRepository> mockFormatRepository = new Mock <IFormatRepository>();
            IFormatManagementService formatLogic          = new FormatManagementService
            {
                FormatRepository = mockFormatRepository.Object
            };

            Format fakeFormat = new Format
            {
                Name = "Normal"
            };

            mockFormatRepository
            .Setup(wl => wl.Exists("Normal"))
            .Returns(true);
            mockFormatRepository
            .Setup(wl => wl.GetByName("Normal"))
            .Returns(fakeFormat);

            Format result = formatLogic.GetByName("Normal");

            mockFormatRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(fakeFormat, result);
        }
        public void TestGetAllFormatsCallsRepositoryGetAll()
        {
            Mock <IFormatRepository> mockFormatRepository = new Mock <IFormatRepository>();
            IFormatManagementService formatLogic          = new FormatManagementService
            {
                FormatRepository = mockFormatRepository.Object
            };

            IEnumerable <Format> fakeFormats = GetFakeFormats();

            mockFormatRepository
            .Setup(wl => wl.GetAll())
            .Returns(fakeFormats);

            IEnumerable <Format> results = formatLogic.GetAll();

            mockFormatRepository.VerifyAll();
            Assert.IsNotNull(results);
            Assert.IsTrue(fakeFormats.SequenceEqual(results));
        }
        public void TestDeleteFormatFailsOnMissingFormat()
        {
            Mock <IFormatRepository> mockFormatRepository = new Mock <IFormatRepository>();
            IFormatManagementService formatLogic          = new FormatManagementService
            {
                FormatRepository = mockFormatRepository.Object
            };



            mockFormatRepository
            .Setup(wl => wl.Exists("Normal"))
            .Returns(false);
            mockFormatRepository
            .Setup(wl => wl.Delete("Normal"))
            ;

            formatLogic.Delete("Normal");

            mockFormatRepository.VerifyAll();
        }
        public void TestAddFormatFailsOnExistingFormat()
        {
            Mock <IFormatRepository> mockFormatRepository = new Mock <IFormatRepository>();
            IFormatManagementService formatLogic          = new FormatManagementService
            {
                FormatRepository = mockFormatRepository.Object
            };

            Format fakeFormat = new Format
            {
                Name = "Normal"
            };

            mockFormatRepository
            .Setup(wl => wl.Exists("Normal"))
            .Returns(true);
            mockFormatRepository
            .Setup(wl => wl.Add(fakeFormat));

            Format result = formatLogic.Add(fakeFormat);

            mockFormatRepository.VerifyAll();
        }
        public void TestAddFormatWorksOnMissingFormat()
        {
            Mock <IFormatRepository> mockFormatRepository = new Mock <IFormatRepository>();
            IFormatManagementService formatLogic          = new FormatManagementService
            {
                FormatRepository = mockFormatRepository.Object
            };

            Format fakeFormat = new Format
            {
                Name = "Normal"
            };

            mockFormatRepository
            .Setup(wl => wl.Exists("Normal"))
            .Returns(false);
            mockFormatRepository
            .Setup(wl => wl.Add(fakeFormat));

            Format result = formatLogic.Add(fakeFormat);

            mockFormatRepository.VerifyAll();
            Assert.AreEqual(result, fakeFormat);
        }