Esempio n. 1
0
        public void GetRideLevel_ReturnsNormalWith5Rides()
        {
            //Arrange
            Member    member = new Member();
            Ride      ride1  = new Ride();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Easy;
            ride1.Route      = route;
            member.Add(ride1);
            Ride ride2 = new Ride();

            ride2.Route = route;
            member.Add(ride2);
            Ride ride3 = new Ride();

            ride3.Route = route;
            member.Add(ride3);
            Ride ride4 = new Ride();

            ride4.Route = route;
            member.Add(ride4);
            Ride ride5 = new Ride();

            ride5.Route = route;
            member.Add(ride5);
            Difficulty expectedDifficulty = Difficulty.Normal;

            //Act
            Difficulty actualDiffculty = member.RideLevel;

            //Assert
            Assert.Equal(expectedDifficulty, actualDiffculty);
        }
Esempio n. 2
0
        public void GetRideLevel_ReturnsNormalWith12Rides4IsNormal()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();
            BikeRoute route2 = new BikeRoute();

            route.Difficulty  = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            for (int i = 0; i < 8; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            for (int i = 0; i < 4; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Normal;

            Difficulty actualDifficulty = member.RideLevel;

            Assert.Equal <Difficulty>(expectedDifficulty, actualDifficulty);
        }
Esempio n. 3
0
        public void GetRideLevel_ReturnsHardWith12Rides5IsNormal()
        {
            Member    member = new Member();
            BikeRoute route1 = new BikeRoute();
            BikeRoute route2 = new BikeRoute();

            route1.Difficulty = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            for (int i = 0; i < 7; i++)
            {
                Ride ride = new Ride();
                ride.Route = route1;
                member.Add(ride);
            }
            for (int i = 0; i < 5; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Hard;

            //Act
            Difficulty actualDiffculty = member.RideLevel;

            //Assert
            Assert.Equal(expectedDifficulty, actualDiffculty);
        }
Esempio n. 4
0
        public void GetRideLevel_ReturnsHardWith30Rides9IsHard()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();
            BikeRoute route2 = new BikeRoute();
            BikeRoute route3 = new BikeRoute();

            route.Difficulty  = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            route3.Difficulty = Difficulty.Hard;
            for (int i = 0; i < 7; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            for (int i = 0; i < 5; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            for (int i = 0; i < 9; i++)
            {
                Ride ride = new Ride();
                ride.Route = route3;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Hard;

            Difficulty actualDifficulty = member.RideLevel;

            Assert.Equal <Difficulty>(expectedDifficulty, actualDifficulty);
        }
Esempio n. 5
0
 public void Add(string playerId)
 {
     lock (Member)
     {
         Member.Add(playerId);
     }
 }
 private static IEnumerable <Member> GetMemberResults(MemberMetrics metrics)
 {
     foreach (MemberMetric memberMetric in metrics.Results)
     {
         Member member = new Member();
         member.Name = memberMetric.Name;
         Member member1  = member;
         string codeFile = memberMetric.CodeFile;
         if (codeFile == null)
         {
             codeFile = string.Empty;
         }
         member1.File = codeFile;
         member.Line  = memberMetric.LineNumber;
         Member member2 = member;
         if (memberMetric.Kind == MemberMetricKind.Method)
         {
             member2.Kind = "Method";
         }
         else if (memberMetric.Kind == MemberMetricKind.PropertyAccessor)
         {
             member2.Kind = "Property";
         }
         else if (memberMetric.Kind == MemberMetricKind.EventAccessor)
         {
             member2.Kind = "Event";
         }
         if (memberMetric.Metrics != null)
         {
             member2.Add(MetricsReportBuilder.GetMetricsResult(memberMetric.Metrics));
         }
         yield return(member2);
     }
 }
Esempio n. 7
0
 public void AddMember(Transform newMember, int index, Vector3?nuetoralPosition)
 {
     Member.Add(newMember);
     if (index == 0)
     {
         this.NeutoralPosition = nuetoralPosition.Value;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// It generates add member with existing VCKey using SOAP service
        /// </summary>
        /// <returns>Member Details</returns>
        public Member GenerateAddMemberForSOAPExistingVC()
        {
            Member      member = new Member();
            VirtualCard vc     = new VirtualCard();

            vc.LoyaltyIdNumber = DatabaseUtility.GetExistingLoyaltyCardIDwithActiveStatus();
            member.Add(vc);
            return(member);
        }
Esempio n. 9
0
        /// <summary>
        /// It generates add member with mandatory fields using SOAP service
        /// </summary>
        /// <returns>Member Details</returns>
        public Member GenerateaddMemberForSOAPMandatory()
        {
            Member      member = new Member();
            VirtualCard vc     = new VirtualCard();

            vc.LoyaltyIdNumber = new System.Random().Next(1, 9999999).ToString();
            member.Add(vc);
            return(member);
        }
Esempio n. 10
0
        public void AddRide_ReturnsFalseRideWasntAdded()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Normal;
            Ride ride = new Ride();

            ride.Route = route;

            Assert.False(member.Add(ride));
        }
Esempio n. 11
0
        public void AddRide_ReturnsTrueRideWasAdded()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Easy;
            Ride ride = new Ride();

            ride.Route = route;

            Assert.True(member.Add(ride));
        }
Esempio n. 12
0
        public void GetRideLevel_ReturnsExpertWith30Rides()
        {
            Member member = new Member();

            member.EnrollmentDate = DateTime.Parse("2017-05-20");
            BikeRoute route1 = new BikeRoute();
            BikeRoute route2 = new BikeRoute();
            BikeRoute route3 = new BikeRoute();

            route1.Difficulty = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            route3.Difficulty = Difficulty.Hard;
            for (int i = 0; i < 7; i++)
            {
                Ride ride = new Ride();
                ride.Route = route1;
                member.Add(ride);
            }
            for (int i = 0; i < 13; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route3;
                member.Add(ride);
            }

            Difficulty expectedDifficulty = Difficulty.Expert;

            //Act
            Difficulty actualDiffculty = member.RideLevel;

            //Assert
            Assert.Equal(expectedDifficulty, actualDiffculty);
        }
Esempio n. 13
0
        public void GetRideLevel_ReturnsExpertWith30Rides() // Partial solution to an issue suggested by Morten
        {
            Member member = new Member();

            member.EnrollmentDate = DateTime.Today.AddYears(-2);
            BikeRoute route  = new BikeRoute();
            BikeRoute route2 = new BikeRoute();
            BikeRoute route3 = new BikeRoute();

            route.Difficulty  = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            route3.Difficulty = Difficulty.Hard;
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route3;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Expert;

            Difficulty actualDifficulty = member.RideLevel;

            Assert.Equal <Difficulty>(expectedDifficulty, actualDifficulty);
        }
Esempio n. 14
0
        public void GetRideLevel_ReturnsHardWith30Rides10IsHardLessThan1Year()
        {
            Member member = new Member();

            member.EnrollmentDate = DateTime.Today;
            BikeRoute route  = new BikeRoute();
            BikeRoute route2 = new BikeRoute();
            BikeRoute route3 = new BikeRoute();

            route.Difficulty  = Difficulty.Easy;
            route2.Difficulty = Difficulty.Normal;
            route3.Difficulty = Difficulty.Hard;
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route2;
                member.Add(ride);
            }
            for (int i = 0; i < 10; i++)
            {
                Ride ride = new Ride();
                ride.Route = route3;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Hard;

            Difficulty actualDifficulty = member.RideLevel;

            Assert.Equal <Difficulty>(expectedDifficulty, actualDifficulty);
        }
Esempio n. 15
0
        public ActionResult Add(MemberModel member)
        {
            Member       memberBusiness = BusinessFactory.getMember(this.getRuleConfig());
            MemberObject memberObject   = new MemberObject
            {
                FirstName     = member.FirstName,
                LastName      = member.LastName,
                Age           = member.Age,
                Gender        = member.Gender,
                Habits        = member.Habits,
                PreConditions = member.PreConditions
            };

            memberBusiness.Add(memberObject);
            return(Redirect("/Home/Index"));
        }
Esempio n. 16
0
        /// <summary>
        /// It generates add member using SOAP service
        /// </summary>
        /// <returns>Memeber Details</returns>
        public Member GenerateAddMemberForSOAP()
        {
            Member member = new Member();

            member.FirstName        = "CDIS_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male);
            member.LastName         = "CDIS_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male);
            member.Username         = member.FirstName;
            member.Password         = "******";
            member.MemberCreateDate = System.DateTime.Now;
            Logger.Info(member.FirstName);
            VirtualCard vc = new VirtualCard();

            vc.LoyaltyIdNumber = new System.Random().Next(1, 9999999).ToString();
            member.Add(vc);
            return(member);
        }
Esempio n. 17
0
        public void AddRide_ReturnsFalseRideWasntAdded()
        {
            //Arrange
            Member    member    = new Member();
            BikeRoute bikeRoute = new BikeRoute();

            bikeRoute.Difficulty = Difficulty.Hard;
            Ride ride = new Ride();

            ride.Route = bikeRoute;


            //Act

            //Assert
            Assert.False(member.Add(ride));
        }
Esempio n. 18
0
        public void AddRide_ReturnsTrueRideWasAdded()
        {
            //Arrange
            Member    member    = new Member();
            BikeRoute bikeRoute = new BikeRoute();

            bikeRoute.Difficulty = Difficulty.Easy;
            Ride ride = new Ride();

            ride.Route = bikeRoute;


            //Act

            //Assert
            Assert.True(member.Add(ride));
        }
Esempio n. 19
0
        public void GetRideLevel_ReturnsEasyWith4Rides()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Easy;
            for (int i = 0; i < 4; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Easy;

            Difficulty actualDifficulty = member.RideLevel;

            Assert.Equal <Difficulty>(expectedDifficulty, actualDifficulty);
        }
Esempio n. 20
0
        public void GetRideLevel_ReturnsNormalWith11Rides()
        {
            //Arrange
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Easy;
            for (int i = 0; i < 11; i++)
            {
                Ride ride = new Ride();
                ride.Route = route;
                member.Add(ride);
            }
            Difficulty expectedDifficulty = Difficulty.Normal;

            //Act
            Difficulty actualDiffculty = member.RideLevel;

            //Assert
            Assert.Equal(expectedDifficulty, actualDiffculty);
        }
 public PhoneNumber(string n, string num) : this()
 {
     Member.Add(n, num);
 }
Esempio n. 22
0
        /// <summary>
        /// It generates add member with all fields using SOAP service
        /// </summary>
        /// <returns>Member Details</returns>
        public Member AddMemberWithAllFields()
        {
            Member member = new Member();

            member.IpCode              = Convert.ToInt64(RandomNumber(6));
            member.MemberCreateDate    = System.DateTime.Now;
            member.MemberCloseDate     = System.DateTime.Now.AddYears(20);
            member.BirthDate           = System.DateTime.Now.AddYears(-20);
            member.FirstName           = "SOAP_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male);
            member.LastName            = "SOAP_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male);
            member.MiddleName          = "SOAP_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male);
            member.NamePrefix          = "MR.";
            member.NameSuffix          = "";
            member.Username            = member.FirstName;
            member.Password            = "******";
            member.PrimaryEmailAddress = member.FirstName + "@Test.Com";
            member.PrimaryPhoneNumber  = "7" + RandomNumber(9);
            member.PrimaryPostalCode   = RandomNumber(1) + RandomNumber(4);
            member.PreferredLanguage   = "en";
            member.IsEmployee          = false;
            member.ChangedBy           = "SOAP_Automation";

            MemberDetails details = new MemberDetails();

            details.EmailOptIn             = true;
            details.EmailOptInDate         = System.DateTime.Now;
            details.AddressLineOne         = "Automation Test Dr";
            details.AddressLineTwo         = "APT" + RandomNumber(4);
            details.AddressLineThree       = "";
            details.AddressLineFour        = "";
            details.City                   = "Plano";
            details.County                 = "Collin";
            details.StateOrProvince        = "Texas";
            details.Country                = "USA";
            details.SecurityQuestion       = "Which city you were born";
            details.SecurityAnswer         = "Dallas";
            details.TAndCAgreed            = true;
            details.ZipOrPostalCode        = member.PrimaryPostalCode;
            details.Gender                 = Gender.Male.ToString();
            details.SmsOptIn               = true;
            details.MobilePhoneCountryCode = 1;
            details.MobilePhone            = member.PrimaryPhoneNumber;

            details.HomePhone             = null;
            details.HomeStoreID           = null;
            details.WorkPhone             = null;
            details.SecondaryEmailAddress = null;
            details.EmailAddressMailable  = null;
            details.MemberStatusCode      = null;
            details.AddressMailable       = null;
            details.DirectMailOptIn       = null;
            details.DirectMailOptInDate   = null;
            details.SmsDblOptInComplete   = null;
            details.FacebookOptIn         = null;
            details.TwitterOptIn          = null;
            details.EnrollDate            = null;
            details.MemberSource          = null;
            details.SmsConsentChangeDate  = null;
            details.FacebookOptInDate     = null;
            details.TwitterOptInDate      = null;

            VirtualCard vc = new VirtualCard();

            vc.LoyaltyIdNumber = new System.Random().Next(1, 9999999).ToString();
            vc.IpCode          = member.IpCode;
            vc.VcKey           = Convert.ToInt64(RandomNumber(8));
            vc.DateIssued      = System.DateTime.Now;
            vc.DateRegistered  = System.DateTime.Now;
            vc.IsPrimary       = true;
            member.AlternateId = vc.LoyaltyIdNumber;
            member.Add(vc);
            member.Add(details);
            return(member);
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            // Singleton Test
            Console.WriteLine("Singleton Test");

            var singleton = Singleton.CreateSingletonObj(1);

            var singleton2 = Singleton.CreateSingletonObj(2); // не создается новый экземпляр

            // Simple Factory test
            Console.WriteLine(Environment.NewLine + "Simple Factory test");

            SimpleFactory.IWorkerFactory workerFactory = new SimpleFactory.WorkerFactory();
            var simpleFactoryHR = workerFactory.HireWorker(SimpleFactory.WorkerType.HR);

            simpleFactoryHR.GoToWork();

            // Factory test
            Console.WriteLine(Environment.NewLine + "Factory test");

            Factory.IWorkerFactory qAFactory = new Factory.QAFactory();
            Factory.IWorker        factoryQA = qAFactory.HireWorker();
            factoryQA.GoToWork();

            // Abstract factory test
            Console.WriteLine(Environment.NewLine + "Abstract Factory test");

            AbstractFactory.ICompanyFactory companyOneFactory     = new AbstractFactory.CompanyOneFactory();
            AbstractFactory.IWorker         comopanyOneProgrammer = companyOneFactory.GetWorker();
            comopanyOneProgrammer.GoHome();
            AbstractFactory.IVisitor companyOneVisitor = companyOneFactory.GetVisitor();
            companyOneVisitor.Visit();

            // Builder test
            Console.WriteLine(Environment.NewLine + "Builder test");

            Director      director       = new Director();
            IPhoneBuilder androidBuilder = new AndroidPhoneBuilder();

            director.Construct(androidBuilder);
            Console.WriteLine(androidBuilder.Phone.ToString());

            // Decorator test
            Console.WriteLine(Environment.NewLine + "Decorator test");

            Employee programmer = new Programmer();

            programmer = new Junior(programmer);
            Console.WriteLine(programmer);

            Employee qA = new QA();

            qA = new Middle(qA);
            Console.WriteLine(qA);

            // Adapter test
            Console.WriteLine(Environment.NewLine + "Adapter test");

            Company company = new Company();

            CompanyOneEmployee companyOneEmployee = new CompanyOneEmployee();

            company.TransferEmployee(companyOneEmployee);

            CompanyTwoEmployee companyTwoEmployee = new CompanyTwoEmployee();
            ITransferable      employeeAdapter    = new EmployeeAdapter(companyTwoEmployee);

            company.TransferEmployee(employeeAdapter);

            // Composite test
            Console.WriteLine(Environment.NewLine + "Composite test");

            Component headOfDepartment = new Member(Position.HeadOfDepartment, "Vasiliy Michailovich");
            Component firstAssistant   = new Member(Position.Assistant, "Yuri Gagarin");
            Component secondAssistant  = new Member(Position.Assistant, "German Popov");
            Component firstWorker      = new Member(Position.Worker, "Layka");
            Component secondWorker     = new Member(Position.Worker, "Muha");

            headOfDepartment.Add(firstAssistant);
            headOfDepartment.Add(secondAssistant);

            firstAssistant.Add(firstWorker);
            secondAssistant.Add(secondWorker);

            headOfDepartment.Print();

            // Bridge test
            Console.WriteLine(Environment.NewLine + "Bridge test");

            MessageManager messageManager = new SimpleMessageManager(new WebService());

            messageManager.Send("Hellow World!");

            messageManager.Sender = new ThirdPartySender();
            messageManager.Send("Hello World!");

            // Flyweight test
            Console.WriteLine(Environment.NewLine + "Flyweight test");

            Flyweight.ProgrammerFactory programmerFactory = new Flyweight.ProgrammerFactory();

            for (var i = 0; i < 5; i++)
            {
                var fJuniorProgrammer = programmerFactory.GetProgrammer("Junior");
                fJuniorProgrammer.Pay(1.1f);
            }

            Console.WriteLine($"Number of objects in programmerFactory is {programmerFactory.Programmers.Count}");

            // Strategy test
            Console.WriteLine(Environment.NewLine + "Strategy test");

            Strategy.IEmployee       strategyProgrammer = new Strategy.Programmer();
            Strategy.EmployeeActions employeeActions    = new Strategy.EmployeeActions(strategyProgrammer);
            employeeActions.EmployeeGoHome();

            employeeActions.Employee = new Strategy.QA();
            employeeActions.EmployeeGoHome();
        }
Esempio n. 24
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            List <TextBox>     childrenOfMember            = AllChildren(MemberNameStack);
            List <TextBox>     childrenOfTel               = AllChildren(TelStack);
            List <TextBox>     childrenOfExpendituresName  = AllChildren(ExpendituresNameStack);
            List <TextBox>     childrenOfExpendituresMoney = AllChildren(ExpendituresMoneyStack);
            List <RadioButton> childrenOfIsLeader          = AllChildrenRadioButton(IsLeader);

            Trip   trip = new Trip();
            string identity;

            trip.Status = 1;
            int LeaderIndex = -1;

            ///kiểm tra đã nhập đầy đủ thông tin
            if (ConditionCheck(childrenOfMember, childrenOfTel, childrenOfExpendituresName, childrenOfExpendituresMoney))
            {
                //tên chuyến đi
                if (JourneyName.Text.Trim() != "")
                {
                    trip.TripName = JourneyName.Text;
                }

                //số km
                if (Kilometer.Text.Trim() != "")
                {
                    trip.Lenght = Kilometer.Text;
                }

                //ngày đi
                if (StartDay.Text.Trim() != "")
                {
                    trip.StartDate = StartDay.Text;
                }

                //ngày về
                if (EndDay.Text.Trim() != "")
                {
                    trip.EndDate = EndDay.Text;
                }

                for (int i = 0; i < childrenOfIsLeader.Count; i++)
                {
                    if (childrenOfIsLeader[i].IsChecked == true)
                    {
                        LeaderIndex = i;
                        break;
                    }
                }
                //them vào database về chuyến đi
                trip.Add();
                identity = trip.Identyti();;
                //danh sách tên và số điện thoại thành viên
                for (int i = 0; i < childrenOfMember.Count; i++)
                {
                    if (childrenOfMember[i].Text.Trim() != "" && childrenOfTel[i].Text.Trim() != "")
                    {
                        Member member = new Member();
                        member.TripID     = identity;
                        member.MemberName = childrenOfMember[i].Text;
                        member.Telephone  = childrenOfTel[i].Text;
                        if (LeaderIndex == i)
                        {
                            member.Status = 1;
                        }
                        //thêm vào database
                        member.Add();
                    }
                }//kết thúc danh sách tên và số điện thoại thành viên

                Member member1 = new Member();
                //danh sach tên và số tiền khoản chi
                for (int i = 0; i < childrenOfExpendituresMoney.Count; i++)
                {
                    if (childrenOfExpendituresMoney[i].Text.Trim() != "" && childrenOfExpendituresName[i].Text.Trim() != "")
                    {
                        ReceiptsAndExpenses receandexpen = new ReceiptsAndExpenses();
                        member1.Leader(identity);
                        receandexpen.MemberID     = member1.MemberID;
                        receandexpen.TripID       = identity;
                        receandexpen.Cost         = Double.Parse(childrenOfExpendituresMoney[i].Text, System.Globalization.NumberStyles.Any);
                        receandexpen.ExpensesName = childrenOfExpendituresName[i].Text;
                        receandexpen.Add();
                    }
                }//ket thuc lấy danh sach tên và số tiền khoản chi

                MessageBox.Show("Thêm chuyến đi thành công!", "Thành công");
            } //kết thúc thêm vào database
        }     //két thúc sự kiện click
Esempio n. 25
0
 public bool AddMember(Member member)
 {
     return(member.Add());
 }