Пример #1
0
        public void CanAddNewDraft()
        {
            var draft = new Draft
                            {
                                Name = "TestName",
                                CreatedDate = DateTime.Now,
                                MaximumPicksPerMember = 75,
                                Owner = _members[0],
            };

            IDraftRepository repository = new DraftRepository();
            repository.Add(draft);

            // use session to try to load the product
            using (var session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Draft>(draft.Id);
                // Test that the product was successfully inserted

                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(draft, fromDb);
                Assert.AreEqual(draft.Name, fromDb.Name);
                Assert.AreEqual(draft.Public, fromDb.Public);
                Assert.AreEqual(draft.Id, fromDb.Id);
                Assert.AreEqual(draft.Owner.Id, fromDb.Owner.Id);
                Assert.AreEqual(draft.MaximumPicksPerMember, fromDb.MaximumPicksPerMember);

                Assert.AreEqual(draft.CreatedDate.ToString(), fromDb.CreatedDate.ToString());
            }
        }
        public Draft CreateDraft(string draftName, int ownerId, int numberOfPicksPerPlayer, bool isPublic)
        {
            var draft = new Draft
                            {
                                Name = draftName,
                                CreatedDate = DateTime.Now,
                                MaximumPicksPerMember = numberOfPicksPerPlayer,
                                Public = isPublic,
                                Started = false,
                                Finished = false,
                          	};

            IDraftRepository dr = new DraftRepository();
            IDraftMemberPositionsRepository dmpr = new DraftMemberPositionsRepository();
            IMemberRepository mr = new MemberRepository();

            draft.Owner = mr.GetById(ownerId);
            draft.DraftSize = 0;

            dr.Add(draft);

            return draft;
        }