Beispiel #1
0
        public ActionResult SelectReply(int id)
        {
            var repred = CommentRedSpotsManage.FindRedRep(id);

            ViewModels.Brave der = new Brave();
            der.Repred1 = repred;
            return(View(der));
        }
Beispiel #2
0
        public static void GetKeyAsync_Returns_WithoutJoinsCreatingASessionItself()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.GetByKeyAsync <ITestSession>(1).Result);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Beispiel #3
0
        public static void GetKeyAsync_Returns_WithoutJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrowAsync(async() => result = await repo.GetByKeyAsync(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void _3_GetBrave()
        {
            var   target = Container.Resolve <IBarContract>();
            Brave actual = null;

            Assert.DoesNotThrowAsync(async() => actual = await target.GetBrave(1));  //There should be a 1
            actual.Should().NotBeNull();
            Asserters.AssertNew(actual.New);
            Asserters.AssertWorld(actual.World);
        }
Beispiel #5
0
        public static void Get_Returns_CorrectAmountWithJoins()
        {
            var   factory = A.Fake <IDbFactory>();
            var   repo    = new BraveRepository(factory);
            Brave result  = null;

            Assert.DoesNotThrow(() => result = repo.Get(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Beispiel #6
0
        public static void GetAsync_Returns_WithoutJoinsCreatingASessionItself()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrowAsync(async() => result = await repo.GetAsync <ISession>(new Brave {
                Id = 1
            }));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Beispiel #7
0
        public static void Get_Returns_WithoutJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.Get(new Brave {
                Id = 1
            }, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Beispiel #8
0
        public static void GetKeyAsync_Returns_WithoutJoinsWithUnitOrWork()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrowAsync(async() => result = await repo.GetByKeyAsync(1, uow));
            }
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Beispiel #9
0
        public static void Get_Returns_WithJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.GetWithJoins(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
            Assert.That(result.New.Key, Is.EqualTo(3));
            Assert.That(result.New.World.Id, Is.EqualTo(1));
            Assert.That(result.New.World.Guid, Is.Not.Null);
        }
        public static void _3_SaveOrUpdateAsync_Returns_IdForInsertedEnitiyCreatesOwnUnitOfWork()
        {
            var repo     = new BraveRepository(Factory);
            var expected = new Brave
            {
                NewId = 1
            };
            var result = 0;
            var maxId  = repo.GetAll <ITestSession>().Max(x => x.Id);

            Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync <ITestSession>(expected));
            Assert.That(result, Is.EqualTo(++maxId));
        }
Beispiel #11
0
        public static void Get_Returns_WithoutJoinsAndUnitOfWork()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrow(() => result = repo.Get(new Brave {
                    Id = 1
                }, uow));
            }
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void SaveOrUpdate_Returns_IdForInsertedEnitiy()
        {
            var factory  = A.Fake <IDbFactory>();
            var repo     = new BraveRepository(factory);
            var expected = new Brave
            {
                NewId = 1
            };
            int result = 0;

            using (var transaction = Connection.UnitOfWork())
            {
                Assert.DoesNotThrow(() => result = repo.SaveOrUpdate(expected, transaction));
            }
            Assert.That(result, Is.EqualTo(4));
        }
        public static void _3_SaveOrUpdateAsync_Returns_IdForInsertedEnitiy()
        {
            var repo     = new BraveRepository(Factory);
            var expected = new Brave
            {
                NewId = 1
            };
            var result = 0;
            int maxId;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                maxId = repo.GetAll <ITestSession>().Max(x => x.Id);
                Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync(expected, uow));
            }
            Assert.That(result, Is.EqualTo(++maxId));
        }
Beispiel #14
0
        public static void DeleteKey_Removes_EntityOnKeyWithSessionGeneric()
        {
            var repo     = new BraveRepository(Factory);
            var result   = false;
            var expected = new Brave {
                NewId = 2
            };
            var resultBrave = new Brave();

            Assert.DoesNotThrow(() =>
            {
                repo.SaveOrUpdate <ITestSession>(expected);
                result      = repo.DeleteKey <ITestSession>(expected.Id);
                resultBrave = repo.Get <ITestSession>(expected);
            });
            Assert.That(result, Is.True);
            Assert.That(resultBrave, Is.Null);
        }
        public static void DeleteByKeyAsync_Removes_EntityOnKey()
        {
            var repo        = new BraveRepository(Factory);
            var result      = false;
            var expected    = 2;
            var resultBrave = new Brave();

            Assert.DoesNotThrowAsync(async() =>
            {
                using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
                {
                    result      = await repo.DeleteByKeyAsync(expected, uow);
                    resultBrave = await repo.GetByKeyAsync(expected, uow);
                    uow.Rollback();
                }
            });
            Assert.That(result, Is.True);
            Assert.That(resultBrave, Is.Null);
        }
Beispiel #16
0
        private async Task <Response> SaveOrUpdate(Brave model)
        {
            var actual = await _dispatcher.ExecuteAsync <Brave, int>(model);

            return(Response.AsJson(actual));
        }
Beispiel #17
0
 public async Task <int> SaveOrUpdateBrave(Brave brave)
 {
     return(await _dispatcher.ExecuteAsync <Brave, int>(brave));
 }