예제 #1
0
        public void When_RemoveBlogArticle_is_called_with_null_as_BlogArticle_then_an_ArgumentNullException_is_thrown()
        {
            BandCatalog
            .Expect(catalog => catalog.Remove(Arg <BlogArticle> .Is.Anything))
            .Repeat.Never();
            BandCatalog.Replay();

            Repository.RemoveBlogArticle(null);

            BandCatalog.VerifyAllExpectations();
        }
예제 #2
0
        public void When_UpdatePerformance_is_called_with_null_as_Performance_then_an_ArgumentNullException_is_thrown()
        {
            BandCatalog
            .Expect(catalog => catalog.Update(Arg <Performance> .Is.Anything))
            .Return(null)
            .Repeat.Never();
            BandCatalog.Replay();

            Repository.UpdatePerformance(null);

            BandCatalog.VerifyAllExpectations();
        }
예제 #3
0
        public void When_RemovePerformance_is_called_with_a_Performance_then_the_Performance_is_removed_from_the_collection()
        {
            var performance = PerformanceCreator.CreateSingleFuture();

            BandCatalog
            .Expect(catalog => catalog.Remove(performance))
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.RemovePerformance(performance);

            BandCatalog.VerifyAllExpectations();
        }
예제 #4
0
        public void When_RemoveBlogArticle_is_called_with_a_BlogArticle_then_the_BlogArticle_is_removed_from_the_collection()
        {
            var blogArticle = BlogArticleCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Remove(blogArticle))
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.RemoveBlogArticle(blogArticle);

            BandCatalog.VerifyAllExpectations();
        }
예제 #5
0
        public void When_GetBlogArticle_is_called_with_an_Id_and_there_is_no_BlogArticle_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown()
        {
            var blogArticles  = BlogArticleCreator.CreateCollection();
            var blogArticleId = Guid.NewGuid();

            BandCatalog
            .Expect(catalog => catalog.BlogArticles)
            .Return(blogArticles)
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.GetBlogArticle(blogArticleId);
        }
예제 #6
0
        public void When_GetMusician_is_called_with_an_Id_and_there_is_no_Musician_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown()
        {
            var entities = MusicianCreator.CreateCollection();
            var entityId = Guid.NewGuid();

            BandCatalog
            .Expect(catalog => catalog.Musicians)
            .Return(entities)
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.GetMusician(entityId);
        }
예제 #7
0
        public void When_GetPhotoAdapterSettings_is_called_and_there_is_no_PhotoAdapterSettings_in_the_collection_then_an_InvalidOperationException_is_thrown()
        {
            const string adapterName      = "AdapterName";
            var          adapterSettingss = new List <AdapterSettings>().AsQueryable();

            BandCatalog
            .Expect(catalog => catalog.AdapterSettings)
            .Return(adapterSettingss)
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.GetAdapterSettings(adapterName);
        }
예제 #8
0
        public void When_AddMusician_is_called_with_null_as_Musician_then_a_ArgumentNullException_is_thrown()
        {
            BandCatalog
            .Expect(catalog =>
                    catalog.Add(Arg <Musician> .Is.Anything))
            .Return(null)
            .Repeat.Never();
            BandCatalog.Replay();

            Repository.AddMusician(null);

            BandCatalog.VerifyAllExpectations();
        }
예제 #9
0
        public void When_GetPerformance_is_called_with_an_Id_and_there_is_no_Performance_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown()
        {
            var performances  = PerformanceCreator.CreateFutureCollection();
            var performanceId = Guid.NewGuid();

            BandCatalog
            .Expect(catalog => catalog.Performances)
            .Return(performances)
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.GetPerformance(performanceId);
        }
예제 #10
0
        public void When_GetUser_is_called_with_an_Id_and_there_is_no_User_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown()
        {
            var users  = UserCreator.CreateCollection();
            var userId = Guid.NewGuid();

            BandCatalog
            .Expect(catalog => catalog.Users)
            .Return(users)
            .Repeat.Once();
            BandCatalog.Replay();

            Repository.GetUser(userId);
        }
예제 #11
0
        public void When_AddUser_is_called_with_then_the_User_with_is_added_to_the_collection()
        {
            var user = UserCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Add(user))
            .Return(user)
            .Repeat.Once();
            BandCatalog.Replay();

            user = Repository.AddUser(user);

            Assert.IsNotNull(user);

            BandCatalog.VerifyAllExpectations();
        }
예제 #12
0
        public void When_UpdatePerformance_is_called_with_a_Performance_then_the_Performance_is_updated_in_the_collection()
        {
            var performance = PerformanceCreator.CreateSingleFuture();

            BandCatalog
            .Expect(catalog => catalog.Update(performance))
            .Return(performance)
            .Repeat.Once();
            BandCatalog.Replay();

            performance = Repository.UpdatePerformance(performance);

            Assert.IsNotNull(performance);

            BandCatalog.VerifyAllExpectations();
        }
예제 #13
0
        public void When_UpdateBlogArticle_is_called_with_a_BlogArticle_then_the_BlogArticle_is_updated_in_the_collection()
        {
            var blogArticle = BlogArticleCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Update(blogArticle))
            .Return(blogArticle)
            .Repeat.Once();
            BandCatalog.Replay();

            blogArticle = Repository.UpdateBlogArticle(blogArticle);

            Assert.IsNotNull(blogArticle);

            BandCatalog.VerifyAllExpectations();
        }
예제 #14
0
        public void When_AddMusician_is_called_with_then_the_Musician_is_added_to_the_collection()
        {
            var entity = MusicianCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Add(entity))
            .Return(entity)
            .Repeat.Once();
            BandCatalog.Replay();

            entity = Repository.AddMusician(entity);

            Assert.IsNotNull(entity);

            BandCatalog.VerifyAllExpectations();
        }
예제 #15
0
        public void When_UpdateMusician_is_called_with_a_valid_Musician_then_the_Musician_is_updated_in_the_collection()
        {
            var entity = MusicianCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Update(entity))
            .Return(entity)
            .Repeat.Once();
            BandCatalog.Replay();

            entity = Repository.UpdateMusician(entity);

            Assert.IsNotNull(entity);

            BandCatalog.VerifyAllExpectations();
        }
예제 #16
0
        public void When_UpdateUser_is_called_with_a_valid_User_then_the_User_with_is_updated_in_the_collection()
        {
            var user = UserCreator.CreateSingle();

            BandCatalog
            .Expect(catalog => catalog.Update(user))
            .Return(user)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.UpdateUser(user);

            Assert.IsNotNull(result);
            Assert.AreEqual(user.Id, result.Id);

            BandCatalog.VerifyAllExpectations();
        }
예제 #17
0
        public void When_GetAllBlogArticles_is_called_then_all_BlogArticles_are_retrieved_from_the_collection()
        {
            var blogArticles = BlogArticleCreator.CreateCollection();

            BandCatalog
            .Expect(catalog => catalog.BlogArticles)
            .Return(blogArticles)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAllBlogArticles();

            Assert.IsNotNull(result);
            Assert.AreEqual(blogArticles.Count(), result.Count());

            BandCatalog.VerifyAllExpectations();
        }
예제 #18
0
        public void When_GetBlogArticle_is_called_with_an_Id_then_the_BlogArticle_with_the_corresponding_Id_is_retrieved_from_the_collection()
        {
            var blogArticles  = BlogArticleCreator.CreateCollection();
            var blogArticleId = blogArticles.ElementAt(2).Id;

            BandCatalog
            .Expect(catalog => catalog.BlogArticles)
            .Return(blogArticles)
            .Repeat.Once();
            BandCatalog.Replay();

            var blogArticle = Repository.GetBlogArticle(blogArticleId);

            Assert.IsNotNull(blogArticle);
            Assert.AreEqual(blogArticleId, blogArticle.Id);

            BandCatalog.VerifyAllExpectations();
        }
예제 #19
0
        public void When_GetAllPhotoAdapterSettingss_is_called_and_there_are_more_than_one_PhotoAdapterSettingss_instances_stored_then_only_the_first_instance_is_retrieved_from_the_collection()
        {
            const string adapterName     = "AdapterName";
            var          adapterSettings = AdapterSettingsCreator.CreateCollection(adapterName, adapterName, adapterName);

            BandCatalog
            .Expect(catalog => catalog.AdapterSettings)
            .Return(adapterSettings)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAdapterSettings(adapterName);

            Assert.IsNotNull(result);
            Assert.AreEqual(adapterSettings.First(), result);

            BandCatalog.VerifyAllExpectations();
        }
예제 #20
0
        public void When_GetAllMusicians_is_called_then_all_Musicians_are_retrieved_from_the_collection()
        {
            var entities = MusicianCreator.CreateCollection();

            BandCatalog
            .Expect(catalog => catalog.Musicians)
            .Return(entities)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAllMusicians();

            Assert.IsNotNull(result);
            Assert.AreEqual(entities.Count(), result.Count());
            Assert.AreEqual(entities, result);

            BandCatalog.VerifyAllExpectations();
        }
예제 #21
0
        public void When_UpdatePhotoAdapterSettings_is_called_with_a_PhotoAdapterSettings_then_the_PhotoAdapterSettings_with_is_updated_in_the_collection()
        {
            const string adapterName     = "AdapterName";
            var          adapterSettings = AdapterSettingsCreator.CreateSingle(adapterName);

            BandCatalog
            .Expect(catalog => catalog.Update(adapterSettings))
            .Return(adapterSettings)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.UpdateAdapterSettings(adapterSettings);

            Assert.IsNotNull(result);
            Assert.AreEqual(adapterSettings, result);

            BandCatalog.VerifyAllExpectations();
        }
예제 #22
0
        public void When_GetMusician_is_called_with_an_Id_then_the_Musician_with_the_corresponding_Id_is_retrieved_from_the_collection()
        {
            var entities = MusicianCreator.CreateCollection();
            var entityId = entities.ElementAt(2).Id;

            BandCatalog
            .Expect(catalog => catalog.Musicians)
            .Return(entities)
            .Repeat.Once();
            BandCatalog.Replay();

            var entity = Repository.GetMusician(entityId);

            Assert.IsNotNull(entity);
            Assert.AreEqual(entityId, entity.Id);

            BandCatalog.VerifyAllExpectations();
        }
예제 #23
0
        public void When_GetPerformance_is_called_with_an_Id_then_the_Performance_with_the_corresponding_Id_is_retrieved_from_the_collection()
        {
            var performances  = PerformanceCreator.CreateFutureCollection();
            var performanceId = performances.ElementAt(2).Id;

            BandCatalog
            .Expect(catalog => catalog.Performances)
            .Return(performances)
            .Repeat.Once();
            BandCatalog.Replay();

            var performance = Repository.GetPerformance(performanceId);

            Assert.IsNotNull(performance);
            Assert.AreEqual(performanceId, performance.Id);

            BandCatalog.VerifyAllExpectations();
        }
예제 #24
0
        public void When_GetAllUsers_is_called_then_all_Users_are_retrieved_from_the_collection()
        {
            var users = UserCreator.CreateCollection();

            BandCatalog
            .Expect(catalog => catalog.Users)
            .Return(users)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAllUsers();

            Assert.IsNotNull(result);
            Assert.AreEqual(users.Count(), result.Count());
            Assert.AreEqual(users, result);

            BandCatalog.VerifyAllExpectations();
        }
예제 #25
0
        public void When_GetUser_is_called_with_an_Id_then_the_User_with_the_corresponding_Id_is_retrieved_from_the_collection()
        {
            var users  = UserCreator.CreateCollection();
            var userId = users.ElementAt(2).Id;

            BandCatalog
            .Expect(catalog => catalog.Users)
            .Return(users)
            .Repeat.Once();
            BandCatalog.Replay();

            var user = Repository.GetUser(userId);

            Assert.IsNotNull(user);
            Assert.AreEqual(userId, user.Id);

            BandCatalog.VerifyAllExpectations();
        }
예제 #26
0
        public void When_GetPhotoAdapterSettings_is_called_then_the_PhotoAdapterSettings_is_retrieved_from_the_collection()
        {
            const string adapterName     = "AdapterName";
            var          adapterSettings = AdapterSettingsCreator.CreateSingle(adapterName);

            BandCatalog
            .Expect(catalog => catalog.AdapterSettings)
            .Return(new List <AdapterSettings> {
                adapterSettings
            }.AsQueryable())
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAdapterSettings(adapterName);

            Assert.IsNotNull(result);
            Assert.AreEqual(adapterSettings, result);

            BandCatalog.VerifyAllExpectations();
        }
예제 #27
0
        public void When_GetAllPastPerformances_is_called_then_all_past_Performances_are_retrieved_from_the_collection()
        {
            var futurePerformances = PerformanceCreator.CreateFutureCollection();
            var pastPerformances   = PerformanceCreator.CreatePastCollection();
            var performances       = pastPerformances.Union(futurePerformances);

            BandCatalog
            .Expect(catalog => catalog.Performances)
            .Return(performances)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetAllPastPerformances();

            Assert.IsNotNull(result);
            Assert.AreEqual(pastPerformances.Count(), result.Count());
            Assert.AreEqual(pastPerformances.First(), result.First());

            BandCatalog.VerifyAllExpectations();
        }
예제 #28
0
        public void When_GetPerformances_is_called_then_the_specified_number_of_future_Performances_are_retrieved_from_the_collection()
        {
            const int page     = 0;
            const int pageSize = 3;

            var futurePerformances = PerformanceCreator.CreateFutureCollection();
            var pastPerformances   = PerformanceCreator.CreatePastCollection();
            var performances       = pastPerformances.Union(futurePerformances);

            BandCatalog
            .Expect(catalog => catalog.Performances)
            .Return(performances)
            .Repeat.Once();
            BandCatalog.Replay();

            var result = Repository.GetFuturePerformances(page, pageSize);

            Assert.IsNotNull(result);
            Assert.AreEqual(pageSize, result.Count());
            Assert.AreEqual(futurePerformances.First(), result.First());

            BandCatalog.VerifyAllExpectations();
        }