Example #1
0
        public void GetEntity_GetEntityFuncLambda_RealEntity()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);

            InfoEntity infoEntity = DbMock.GetEntity <InfoEntity>(x => x.Email == "*****@*****.**" && x.Name == "cName").FirstOrDefault();

            Assert.AreEqual(infoEntity.Id, ObjectId.Parse("5c89c3212000000000000000"));
        }
Example #2
0
        public void GetEntity_GetEntityFuncLambda_Null()
        {
            DbMock = new MongoDbContext();
            InfoEntity infoEntity = DbMock.GetEntity <InfoEntity>(x => x.Id == ObjectId.Parse("5c89c3b00000000012341234")).FirstOrDefault();

            Assert.IsNull(infoEntity);
        }
Example #3
0
        public void UpdateEntity_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            InfoEntity infoEntityUpdated = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity);

            #region Update element
            DbMock.Update(infoEntityUpdated);
            #endregion

            #region Assert Condition
            InfoEntity retrieveInfoEntity = DbMock.GetEntity <InfoEntity>(x => true).FirstOrDefault();
            Assert.AreEqual(retrieveInfoEntity.Email, "*****@*****.**");
            #endregion
        }
Example #4
0
        public void DeleteEntity_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);

            #region Remove Element
            DbMock.Remove(infoEntity00);
            #endregion

            #region Assert condition
            InfoEntity[] infoEntities = DbMock.GetEntity <InfoEntity>(x => true).ToArray();
            Assert.AreEqual(infoEntities.Length, 1);
            Assert.AreEqual(infoEntities[0].Email, "*****@*****.**");
            #endregion
        }
Example #5
0
        public void AddEntity_Entity_Success()
        {
            DbMock = new MongoDbContext();
            InfoEntity infoEntity = new InfoEntity
            {
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            Enumerable.Range(0, 4).ToList().ForEach(x => DbMock.Add(infoEntity));
            IEnumerable <InfoEntity> populatedMyEntitites = DbMock.GetEntity <InfoEntity>(x => true).ToList();

            Assert.AreEqual(populatedMyEntitites.Count(), 4);
        }
Example #6
0
        public void DeleteEntityUsingExpression_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity00 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity01 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3212000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };
            InfoEntity infoEntity02 = new InfoEntity
            {
                Id       = ObjectId.Parse("5ed6af61b7f0c68829022ebc"),
                Guid     = Guid.Parse("EBDB974B-291B-460A-9F43-871734958676"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity00);
            DbMock.Add(infoEntity01);
            DbMock.Add(infoEntity02);

            #region Remove Element
            DbMock.Remove <InfoEntity>(x => x.Guid == Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"));
            #endregion

            #region Assert condition
            InfoEntity[] infoEntities = DbMock.GetEntity <InfoEntity>(x => true).ToArray();
            Assert.AreEqual(infoEntities.Length, 1);
            Assert.AreEqual(infoEntities[0].Email, "*****@*****.**");
            #endregion
        }
Example #7
0
        public void UpdateEntityWithLambda_Entity_Success()
        {
            DbMock = new MongoDbContext(false);
            InfoEntity infoEntity0 = new InfoEntity
            {
                Id       = ObjectId.Parse("5c89c3b00000000000000000"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            InfoEntity infoEntity1 = new InfoEntity
            {
                Id       = ObjectId.Parse("5ed6d96899609a85c65afac4"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            InfoEntity infoEntity2 = new InfoEntity
            {
                Id       = ObjectId.Parse("5ed6d96dfdeac5b2c020f33c"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            InfoEntity infoEntity3 = new InfoEntity
            {
                Id       = ObjectId.Parse("5ed6d971ee98f12b87cec7fa"),
                Guid     = Guid.Parse("3ABCC35E-D5EF-4514-B913-6D501C301AC0"),
                Email    = "*****@*****.**",
                Name     = "cName",
                Lastname = "cLastname",
                Phone    = "+589 93 956 487"
            };

            DbMock.Add(infoEntity0);
            DbMock.Add(infoEntity1);
            DbMock.Add(infoEntity2);

            #region Update element
            DbMock.Update(x => x.Email == "*****@*****.**", infoEntity3);
            #endregion

            #region Assert Condition
            InfoEntity retrieveRemovedInfoEntity =
                DbMock.GetEntity <InfoEntity>(x => x.Email == "*****@*****.**").
                FirstOrDefault();
            InfoEntity retrieveInfoEntity = DbMock.GetEntity <InfoEntity>(x => x.Email == "*****@*****.**").
                                            FirstOrDefault();
            Assert.IsNull(retrieveRemovedInfoEntity);
            Assert.AreEqual("*****@*****.**", retrieveInfoEntity.Email);
            #endregion
        }