コード例 #1
0
        public void Delete_NonExisting_ExceptionThrown()
        {
            MediaRepository Repository = new MediaRepository(helper);
            Media media = new Media()
            {
                ID = Guid.NewGuid(),
                MediaData = "Update",
                RelationID = this.TestMedia2.RelationID
            };

            Repository.Delete(media);
            Assert.IsNull(Repository.GetByID(media.ID));
        }
コード例 #2
0
ファイル: MediaServiceTests.cs プロジェクト: kiran94/travelme
        public void GetMedia_ValidMedia_ReturnsMedia()
        {
            Media media = new Media()
            {
                ID = Guid.NewGuid(),
                MediaData = "test",
                RelationID = Guid.NewGuid()
            };

            Mock<IRepository<Media>> repository = new Mock<IRepository<Media>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            repository.Setup(o => o.GetByID(It.IsAny<Guid>())).Returns(media);

            MediaService service = new MediaService(repository.Object, loggerService.Object);
            Media retrieved = service.GetMedia(Guid.NewGuid());

            Assert.NotNull(retrieved);
        }
コード例 #3
0
ファイル: MediaService.cs プロジェクト: kiran94/travelme
        /// <summary>
        /// Stored Media
        /// </summary>
        /// <param name="media">Stored media record</param>
        public bool StoreMedia(Media media)
        {
            if(media == null)
            {
                return false;
            }

            try
            {
                this._repository.Insert(media);
                return true;
            }
            catch(Exception e)
            {
                Log log = new Log(e.Message, true);
                this._loggerService.Log(log);
                return false;
            }
        }
コード例 #4
0
        public void InsertSubList_NonExistingEntity_Sucessfull()
        {
            PostRepository Repository = new PostRepository(helper);
            Media media = new Media()
            {
                ID = Guid.NewGuid(),
                MediaData = "test/test/test",
                RelationID = this.TestPost2.ID
            };

            this.TestPost2.Media.Add(media);
            Repository.Update(this.TestPost2, true);

            new MediaRepository(helper).Delete(media);
        }
コード例 #5
0
        public void Update_NonExistingEntity_Saved()
        {
            MediaRepository Repository = new MediaRepository(helper);

            Media media = new Media()
            {
                ID = Guid.NewGuid(),
                MediaData = "Update",
                RelationID = this.TestMedia2.RelationID
            };

            Repository.Update(media, false);

            Assert.AreEqual(media.ID, Repository.GetByID(media.ID).ID);
        }
コード例 #6
0
        public void SetUp()
        {
            Configuration config = new Configuration();
            config.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2012Dialect>();
                db.Driver<SqlClientDriver>();
                db.ConnectionString = "Data Source=DESKTOP-0II3UCP\\MAINSERVER;Initial Catalog=travelme;Integrated Security=True";
            });

            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            config.AddMapping(mapping);

            this.MockConfig = new Mock<IDatabaseConfig>();
            this.MockConfig.SetupSequence(o => o.GetConfig()).Returns(config);

            this.helper = new NhibernateHelper(this.MockConfig.Object);

            this.TestMedia = new Media()
            {
                ID = Guid.Parse("E66E84F1-F9AD-4F29-BA1C-6B38578EE2D8"),
                MediaData = "/Path/Content/Media.jpg",
                RelationID = Guid.Parse("522E9121-3F54-4127-B8A2-530B66E1C42C")
            };

            this.TestMedia2 = new Media()
              {
              ID = Guid.Parse("173EDD9C-DA41-4FA7-9DDA-07664E7DE271"),
              MediaData = "Path",
              RelationID = Guid.Parse("522E9121-3F54-4127-B8A2-530B66E1C42C")
              };
        }