Exemplo n.º 1
0
        public void ShouldInitializeOwlsAtStartingPositions()
        {
            var owls = new Parliament(2);

            owls.AssertPositionsMatch(0, 1);
            Assert.AreEqual(0, owls.InTheNest);
        }
Exemplo n.º 2
0
        //gets members from specific parliament
        public List <CustomPolitcian> GetParliamentWithMembers()
        {
            Parliament             selectedParliament = entities.Parliament.Where(p => p.startYear == 2019).SingleOrDefault();
            var                    members            = entities.ParliamentMember.Where(p => p.parliamentId == selectedParliament.id).ToList();
            List <CustomPolitcian> politcians         = new List <CustomPolitcian>();

            foreach (var member in members)
            {
                var contact = member.Politician.ContactInfo.FirstOrDefault();
                if (contact == null)
                {
                    contact       = new ContactInfo();
                    contact.id    = 0;
                    contact.phone = null;
                    contact.email = null;
                }
                politcians.Add(new CustomPolitcian()
                {
                    PoliticianId = member.Politician.id,
                    ContactId    = contact.id,
                    Firstname    = member.Politician.firstname,
                    Lastname     = member.Politician.lastname,
                    Email        = contact.email,
                    Phone        = contact.phone,
                    Party        = member.Politician.Party.name
                });
            }
            return(politcians);
        }
Exemplo n.º 3
0
        public void ShouldReportOccupancy()
        {
            var owls = new Parliament(2);

            Assert.IsTrue(owls.Inhabit(0));
            Assert.IsFalse(owls.Inhabit(2));
        }
Exemplo n.º 4
0
        public void ShouldPerformNestAction()
        {
            var owls = new Parliament(2);

            owls.Nest(0);

            owls.AssertPositionsMatch(1);
            Assert.AreEqual(1, owls.InTheNest);
        }
Exemplo n.º 5
0
        public void ShouldPerformMoveAction()
        {
            var owls = new Parliament(2);

            owls.Move(0, 2);

            owls.AssertPositionsMatch(1, 2);
            Assert.AreEqual(0, owls.InTheNest);
        }
Exemplo n.º 6
0
        public void ShouldNotBeEqualIfTheOwlsAreInDifferentPositions()
        {
            var lazyOwls   = new Parliament(2);
            var activeOwls = lazyOwls.Clone();

            activeOwls.Move(0, 2);

            Assert.AreNotEqual(lazyOwls, activeOwls);
        }
Exemplo n.º 7
0
        //Create new parliament
        public void AddParliament()
        {
            Parliament parliament = new Parliament();
            DateTime   date       = DateTime.Now;

            parliament.startYear = date.Year;
            entities.Parliament.Add(parliament);
            entities.SaveChanges();
        }
Exemplo n.º 8
0
        public void ShouldEqualItsClone()
        {
            var initialOwls = new Parliament(2);
            var clonedOwls  = initialOwls.Clone();

            Assert.AreNotSame(initialOwls, clonedOwls);
            clonedOwls.AssertPositionsMatch(initialOwls);
            Assert.AreEqual(initialOwls.Count, clonedOwls.Count);
            Assert.AreEqual(initialOwls, clonedOwls);
        }
Exemplo n.º 9
0
        public void ShouldThrowWhenReferencingNonowl()
        {
            var owls = new Parliament(2);

            Assert.ThrowsException <InvalidMoveException>(() => {
                owls.Move(2, 10);
            });
            Assert.ThrowsException <InvalidMoveException>(() => {
                owls.Nest(2);
            });
        }
Exemplo n.º 10
0
        public void ShouldNotBeEqualIfTheyHaveDifferentOwlCounts()
        {
            var twoOwls   = new Parliament(2);
            var threeOwls = new Parliament(3);

            threeOwls.Nest(threeOwls.LeadOwl);

            twoOwls.AssertPositionsMatch(threeOwls);
            Assert.AreEqual(0, twoOwls.InTheNest);
            Assert.AreEqual(1, threeOwls.InTheNest);
            Assert.AreNotEqual(twoOwls, threeOwls);
        }
Exemplo n.º 11
0
        public void ShouldBeEqualIfTheyRepresentTheSameState()
        {
            var someOwls      = new Parliament(2);
            var identicalOwls = new Parliament(2);

            someOwls.Nest(someOwls.TrailingOwl);
            someOwls.Move(someOwls.LeadOwl, 20);

            // The same actions in the other order should be equivalent.
            identicalOwls.Move(identicalOwls.LeadOwl, 20);
            identicalOwls.Nest(identicalOwls.TrailingOwl);

            Assert.AreEqual(someOwls, identicalOwls);
        }
Exemplo n.º 12
0
        public void GetTenantData(ref string pCode, out string tenantName, out int parliamentId, out string tenantSubDomain)
        {
            string     code       = pCode;
            Parliament parliament = null;

            parliament = GetAllParliamentsCached().SingleOrDefault(x => x.Code.Equals(code, StringComparison.InvariantCultureIgnoreCase));

            if (parliament == null)
            {
                parliament = GetDefaultParliament();
            }

            pCode           = parliament.Code;
            tenantName      = parliament.Tenant;
            parliamentId    = parliament.ParliamentID;
            tenantSubDomain = parliament.TenantSubDomain;
        }
Exemplo n.º 13
0
        private static void PopulateParliaments(JavnaRasprava.WEB.DomainModels.ApplicationDbContext context)
        {
            var stateParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_STATE
            };
            var federalParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_FEDERAL
            };
            var rsParliament = new Parliament
            {
                Name = StringConstants.PARLIAMENT_NAME_RS
            };

            context.Parliaments.AddOrUpdate(p => p.Name, stateParliament, federalParliament, rsParliament);

            context.SaveChanges();
        }
        public DataTable GetDataTableParliament(DO_ParliamentDebates objParliments, Parliament flag)
        {
            //For Retriving Record For Parliament Debate

            DataTable     dt   = new DataTable();
            SqlConnection conn = new SqlConnection();
            SQLManager    co   = new SQLManager();

            conn = co.GetConnection();
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand             = new SqlCommand("Scrl_AddEditDelParliamentDebates", conn);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value             = flag;
            da.SelectCommand.Parameters.Add("@DebateId", SqlDbType.BigInt).Value        = objParliments.DebateId;
            da.SelectCommand.Parameters.Add("@AddedBy", SqlDbType.BigInt).Value         = objParliments.AddedBy;
            da.SelectCommand.Parameters.Add("@Condition", SqlDbType.VarChar, 500).Value = objParliments.Condition;
            da.Fill(dt);
            co.CloseConnection(conn);
            return(dt);
        }
        public void AddEditDel_Parliments(DO_ParliamentDebates objParliments, Parliament flag)
        {
            SqlConnection conn = new SqlConnection();
            SQLManager    co   = new SQLManager();

            conn = co.GetConnection();


            cmd             = new SqlCommand("Scrl_AddEditDelParliamentDebates", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@FlagNo", SqlDbType.Int).Value            = flag;
            cmd.Parameters.Add("@DebateId", SqlDbType.BigInt).Value       = objParliments.DebateId;
            cmd.Parameters.Add("@DebateDate", SqlDbType.DateTime).Value   = objParliments.DebateDate;
            cmd.Parameters.Add("@Session", SqlDbType.VarChar, 500).Value  = objParliments.Session;
            cmd.Parameters.Add("@Member", SqlDbType.VarChar, 500).Value   = objParliments.Member;
            cmd.Parameters.Add("@DebateType", SqlDbType.Int).Value        = objParliments.DebateType;
            cmd.Parameters.Add("@Subject", SqlDbType.Text).Value          = objParliments.Subject;
            cmd.Parameters.Add("@AddedBy", SqlDbType.BigInt).Value        = objParliments.AddedBy;
            cmd.Parameters.Add("@Modifiedby", SqlDbType.BigInt).Value     = objParliments.Modifiedby;
            cmd.Parameters.Add("@IPAddress", SqlDbType.VarChar, 50).Value = objParliments.IPAddress;
            cmd.ExecuteNonQuery();
            co.CloseConnection(conn);
        }
Exemplo n.º 16
0
 public static void AssertPositionsMatch(this Parliament owls, Parliament otherOwls)
 {
     owls.AssertPositionsMatch(otherOwls.ListOfPositions.ToArray());
 }
Exemplo n.º 17
0
 public SubmitBillEffect(Bill bill, Parliament parliament)
 {
     Bill       = bill;
     Parliament = parliament;
 }
Exemplo n.º 18
0
 public static void AssertPositionsMatch(this Parliament owls, params int[] expectedPositions)
 {
     CollectionAssert.AreEquivalent(expectedPositions, owls.ListOfPositions.ToList());
 }