Beispiel #1
0
        public async void Validate_User_Create_AND_Retrieve_Single_User()
        {
            var repo = getRepo();

            // Test creating the User
            User resp = await repo.CreateUser(HelperData.User(), HelperData.userImageDTOWithoutData());

            Assert.True(resp.Id > 0);

            // Test retrieving the created User
            User retrieve = await repo.GetSingle(resp.Id);

            Assert.True(retrieve.Id > 0);


            // Clean up by calling Delete
            const string      sp    = "DeleteUser";
            DynamicParameters param = new DynamicParameters();

            param.Add("@UserId", retrieve.Id);

            using (IDbConnection db = fixture.Db)
            {
                await db.ExecuteAsync(sp, param, commandType : CommandType.StoredProcedure);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Method FindArticulations is made for finding articulation
        /// vertices in a graph.
        /// </summary>
        /// <returns>
        /// It returns List<long> where elements of a list are IDs of
        /// articulation vertices.
        /// </returns>
        public static List <int> FindArticulations(Graph g)
        {
            // variable time is a timestamp indicating when was node visited
            HelperData info = new HelperData(g);
            // answer is a list of articlation points
            List <int> answer = new List <int>();

            for (int i = 0; i < g.graph.Count; i++)
            {
                info.low[i]  = Int32.MaxValue;
                info.disc[i] = Int32.MaxValue;
            }
            for (int i = 0; i < g.graph.Count; i++)
            {
                // Start searching for articulations if not visited
                if (!info.visited[i])
                {
                    apDFS(i, i, info);
                }
            }
            for (int i = 0; i < info.articulations.Length; i++)
            {
                if (info.articulations[i])
                {
                    answer.Add(i);
                }
            }
            return(answer);
        }
Beispiel #3
0
        /* Function very similiar to ab function, difference is in comparison
         * signs and 1 less if statement */
        static void bDFS(int v, int parent, List <Edge> ans, HelperData info)
        {
            int children = 0;
            int time     = info.time;

            info.visited[v] = true;
            info.disc[v]    = time;
            info.low[v]     = time;
            foreach (Edge e in info.graph[v])
            {
                children++;
                long next = e.destination;
                if (!info.visited[next])
                {
                    info.time++;
                    bDFS(e.destination, v, ans, info);
                    info.low[v] =
                        Math.Min(info.low[v], info.low[next]);
                    if (info.disc[v] < info.low[next])
                    {
                        ans.Add(e);
                    }
                }
                if (e.destination != parent)
                {
                    info.low[v] =
                        Math.Min(info.low[v], info.low[next]);
                }
            }
        }
Beispiel #4
0
        public List <ReadableSale> GetSpecificWordGroup(string customer, string manufacturer, string keywords, int staff_Id, string helper,
                                                        DateTime salesOrderStartDate, DateTime salesOrderEndDate, DateTime salesStartDate,
                                                        DateTime salesEndDate)
        {
            using (DefaultConnection db = new DefaultConnection())
            {
                SQLWhereString whereString = new SQLWhereString();
                string where = whereString.SearchKeyWhere <ReadableSale>(db, keywords);
                int openCustomer_Id               = BusinessPartnerData.NameToId(db, customer)[0];
                int closeCustomer_Id              = BusinessPartnerData.NameToId(db, customer)[1];
                int openManufacturer_Id           = ManufacturerData.NameToId(db, manufacturer)[0];
                int closeManufacturer_Id          = ManufacturerData.NameToId(db, manufacturer)[1];
                int openStaff_Id                  = StaffData.GetIdRange(db, staff_Id)[0];
                int closeStaff_Id                 = StaffData.GetIdRange(db, staff_Id)[1];
                int openHelper_Id                 = HelperData.NameToId(db, helper)[0];
                int closeHelper_Id                = HelperData.NameToId(db, helper)[1];
                List <ReadableSale> readableSales = new List <ReadableSale>();
                if (!String.IsNullOrEmpty(keywords))
                {
                    readableSales = db.Database
                                    .SqlQuery <ReadableSale>(where)
                                    .ToList();
                    return(readableSales
                           .Where(rs => rs.Customer_Id >= openCustomer_Id &&
                                  rs.Customer_Id <= closeCustomer_Id &&
                                  rs.Manufacturer_Id >= openManufacturer_Id &&
                                  rs.Manufacturer_Id <= closeManufacturer_Id &&
                                  rs.ResponsibleStaff_Id >= openStaff_Id &&
                                  rs.ResponsibleStaff_Id <= closeStaff_Id &&
                                  rs.Helper_Id >= openHelper_Id &&
                                  rs.Helper_Id <= closeHelper_Id &&
                                  rs.SalesOrderDate >= salesOrderStartDate &&
                                  rs.SalesOrderDate <= salesOrderEndDate &&
                                  rs.SalesDate >= salesStartDate &&
                                  rs.SalesDate <= salesEndDate)
                           .ToList());
                }
                else
                {
                    readableSales = db.ReadableSales
                                    .Where(rs => rs.Customer_Id >= openCustomer_Id &&
                                           rs.Customer_Id <= closeCustomer_Id &&
                                           rs.Manufacturer_Id >= openManufacturer_Id &&
                                           rs.Manufacturer_Id <= closeManufacturer_Id &&
                                           rs.ResponsibleStaff_Id >= openStaff_Id &&
                                           rs.ResponsibleStaff_Id <= closeStaff_Id &&
                                           rs.Helper_Id >= openHelper_Id &&
                                           rs.Helper_Id <= closeHelper_Id &&
                                           rs.SalesOrderDate >= salesOrderStartDate &&
                                           rs.SalesOrderDate <= salesOrderEndDate &&
                                           rs.SalesDate >= salesStartDate &&
                                           rs.SalesDate <= salesEndDate)
                                    .ToList();

                    return(readableSales);
                }
            }
        }
        public void isStreet2_Optional()
        {
            var validAddr        = HelperData.Address();
            var validAddrMissing = HelperData.Address();

            validAddrMissing.Street2 = null;

            Assert.True(HelperFunctions.Validate(validAddr));
            Assert.True(HelperFunctions.Validate(validAddrMissing));
        }
        public void isInterests_Optional()
        {
            var validUser        = HelperData.User();
            var validUserMissing = HelperData.User();

            validUserMissing.Interests = null;

            Assert.True(HelperFunctions.Validate(validUser));
            Assert.True(HelperFunctions.Validate(validUserMissing));
        }
        public void areUserClass_Property_Types_Standard()
        {
            var addr = HelperData.Address();

            Assert.IsType <string>(addr.Street1);
            Assert.IsType <string>(addr.Street2);
            Assert.IsType <string>(addr.City);
            Assert.IsType <string>(addr.State);
            Assert.IsType <string>(addr.Zip);
        }
        public void areUserClass_Property_Types_Standard()
        {
            var user = HelperData.User();

            Assert.IsType <int>(user.Id);
            Assert.IsType <string>(user.FirstName);
            Assert.IsType <string>(user.LastName);
            Assert.IsType <DateTime>(user.Birthday);
            Assert.IsType <string>(user.Interests);
            Assert.IsType <Address>(user.Address);
        }
 private static void Register(Data.Packet packet, IPEndPoint endPoint)
 {
     if (!_players.ContainsKey(endPoint))
     {
         var id = HelperData.RandomInt(0, 255);
         _players.Add(endPoint, new PlayerData(endPoint, id));
         Data.Packet packetToSend = new Data.Packet(id, 0, OD_Enum.ACKX, OP_Enum.REGISTER);
         string      stringToSend = packetToSend.Serialize();
         byte[]      bytesToSend  = Encoding.UTF8.GetBytes(stringToSend);
         _listener.Send(bytesToSend, bytesToSend.Length, endPoint);
     }
 }
 private static void StartGame()
 {
     Console.WriteLine(CalculateTime());
     time = CalculateTime();
     //time = 3;
     gameRunning   = true;
     numberToGuess = HelperData.RandomInt(0, 255);
     //numberToGuess = 10;
     Console.WriteLine("Number to guess: {0}", numberToGuess);
     StartClientThreads();
     timer = new Timer(SubstractTime, 5, 0, 1000);
 }
        public void isStreet2_Restricted_In_Length()
        {
            var validAddr        = HelperData.Address();
            var invalidAddrShort = HelperData.Address();
            var invalidAddrLong  = HelperData.Address();

            invalidAddrShort.Street2 = new string('*', 4);
            invalidAddrLong.Street2  = new string('*', 101);

            Assert.True(HelperFunctions.Validate(validAddr));
            Assert.False(HelperFunctions.Validate(invalidAddrShort));
            Assert.False(HelperFunctions.Validate(invalidAddrLong));
        }
        public void isInterests_Restricted_In_Length()
        {
            var validUser        = HelperData.User();
            var invalidUserShort = HelperData.User();
            var invalidUserLong  = HelperData.User();

            invalidUserShort.Interests = new string('*', 2);
            invalidUserLong.Interests  = new string('*', 251);

            Assert.True(HelperFunctions.Validate(validUser));
            Assert.False(HelperFunctions.Validate(invalidUserShort));
            Assert.False(HelperFunctions.Validate(invalidUserLong));
        }
Beispiel #13
0
    public void Init(string name)
    {
        soundManager      = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>();
        dataSavingManager = GameObject.FindGameObjectWithTag("DataSavingManager").GetComponent <DataSavingManager>();
        blockSpawner      = GameObject.FindGameObjectWithTag("BlockSpawner").GetComponent <BlockSpawner>();
        shop       = GameObject.FindGameObjectWithTag("Shop").GetComponent <Shop>();
        helperData = dataSavingManager.GetSkill(name).helperData;

        anim = character.GetComponent <Animator>();

        anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(helperData.helperAnimatorName);

        StartCoroutine(StartCountdown(helperData.idleTime));
    }
        public void isCity_Restricted_In_Length_And_Required()
        {
            var validAddr          = HelperData.Address();
            var invalidAddrShort   = HelperData.Address();
            var invalidAddrLong    = HelperData.Address();
            var invalidAddrMissing = HelperData.Address();

            invalidAddrShort.City   = new string('*', 4);
            invalidAddrLong.City    = new string('*', 51);
            invalidAddrMissing.City = null;

            Assert.True(HelperFunctions.Validate(validAddr));
            Assert.False(HelperFunctions.Validate(invalidAddrShort));
            Assert.False(HelperFunctions.Validate(invalidAddrLong));
            Assert.False(HelperFunctions.Validate(invalidAddrMissing));
        }
        public void isLast_Restricted_In_Length_And_Required()
        {
            var validUser          = HelperData.User();
            var invalidUserShort   = HelperData.User();
            var invalidUserLong    = HelperData.User();
            var invalidUserMissing = HelperData.User();

            invalidUserShort.LastName   = "";
            invalidUserLong.LastName    = new string('*', 51);
            invalidUserMissing.LastName = null;

            Assert.True(HelperFunctions.Validate(validUser));
            Assert.False(HelperFunctions.Validate(invalidUserShort));
            Assert.False(HelperFunctions.Validate(invalidUserLong));
            Assert.False(HelperFunctions.Validate(invalidUserMissing));
        }
        public void isState_Restricted_To_2Characters_And_Required()
        {
            var validAddr          = HelperData.Address();
            var invalidAddrShort   = HelperData.Address();
            var invalidAddrLong    = HelperData.Address();
            var invalidAddrMissing = HelperData.Address();
            var invalidAddrFormat  = HelperData.Address();

            invalidAddrShort.State   = new string("A");
            invalidAddrLong.State    = new string('A', 3);
            invalidAddrMissing.State = null;
            invalidAddrFormat.State  = new string("2A");

            Assert.True(HelperFunctions.Validate(validAddr));
            Assert.False(HelperFunctions.Validate(invalidAddrShort));
            Assert.False(HelperFunctions.Validate(invalidAddrLong));
            Assert.False(HelperFunctions.Validate(invalidAddrMissing));
            Assert.False(HelperFunctions.Validate(invalidAddrFormat));
        }
 //見積データの追加
 public void Create(string customer, string helper, string staff, string[] products_Id)
 {
     using (DefaultConnection db = new DefaultConnection())
     {
         int[] customer_Ids = BusinessPartnerData.NameToId(db, customer);
         int[] helper_Ids   = HelperData.NameToId(db, helper);
         int   customer_Id  = customer_Ids[0];
         int   helper_Id    = helper_Ids[0];
         int   product_Id   = 0;
         int   staff_Id     = StaffData.EmailToId(db, staff);
         foreach (var item in products_Id)
         {
             product_Id = int.Parse(item);
             Quotation quotation = new Quotation(customer_Id, helper_Id, product_Id, staff_Id);
             db.Quotations.Add(quotation);
             db.SaveChanges();
         }
     }
 }
Beispiel #18
0
        /// <summary>
        /// Method FindBridges is called to find bridges in graph.
        /// </summary>
        /// <returns>
        /// It returns List<Edge> that are marked as bridges.
        /// </returns>
        public static List <Edge> FindBridges(Graph g)
        {
            HelperData  info   = new HelperData(g);
            List <Edge> answer = new List <Edge>();

            for (int i = 0; i < g.graph.Count; i++)
            {
                info.low[i]  = Int32.MaxValue;
                info.disc[i] = Int32.MaxValue;
            }
            for (int i = 0; i < g.graph.Count; i++)
            {
                if (!info.visited[i])
                {
                    bDFS(i, i, answer, info);
                }
            }
            return(answer);
        }
        public void isZip_Restricted_To_5Numbers_And_Required()
        {
            var validAddr          = HelperData.Address();
            var invalidAddrShort   = HelperData.Address();
            var invalidAddrLong    = HelperData.Address();
            var invalidAddrMissing = HelperData.Address();
            var invalidAddrFormat  = HelperData.Address();

            invalidAddrShort.Zip   = new string('1', 4);
            invalidAddrLong.Zip    = new string('1', 6);
            invalidAddrMissing.Zip = null;
            invalidAddrFormat.Zip  = new string('*', 5);

            Assert.True(HelperFunctions.Validate(validAddr));
            Assert.False(HelperFunctions.Validate(invalidAddrShort));
            Assert.False(HelperFunctions.Validate(invalidAddrLong));
            Assert.False(HelperFunctions.Validate(invalidAddrMissing));
            Assert.False(HelperFunctions.Validate(invalidAddrFormat));
        }
        public async void Check_Address_Validation_On_Create()
        {
            var mockrepo = new Mock <IUserRepository>();

            mockrepo.Setup(repo => repo.CreateUser(It.IsAny <User>(), It.IsAny <UserImageDTO>()))
            .ReturnsAsync(HelperData.User());

            //Change the FirstName to an INVALID state on the Mapper Response
            var mapperMock = new Mock <IMapper>();

            mapperMock.Setup(m => m.Map <UserDTO, User>(It.IsAny <UserDTO>()))
            .Returns(HelperData.User(City: ""));

            mapperMock.Setup(m => m.Map <User, UserDTO>(It.IsAny <User>()))
            .Returns(HelperData.UserDTO());

            var usersrv = new UserService(mockrepo.Object, mapperMock.Object);

            //Checks model validation before creation
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await usersrv.CreateUser(HelperData.UserDTO()));
        }
Beispiel #21
0
        // Recursive function (modified dfs) that is searching for articulations
        static void apDFS(int v, int parent, HelperData info)
        {
            long children = 0;
            int  time     = info.time;

            // Uploading informations
            info.visited[v] = true;
            info.disc[v]    = time;
            info.low[v]     = time;
            foreach (Edge e in info.graph[v])
            {
                children++;
                int next = e.destination;
                // if a child is not visited, start search from it
                if (!info.visited[next])
                {
                    info.time++;
                    apDFS(e.destination, v, info);

                    /* Compute lowest visitable ancestor and compare it with
                     * current node to determine whether it is an articulation */
                    info.low[v] = Math.Min(info.low[v], info.low[next]);
                    if (info.disc[v] <= info.low[next] && v != parent)
                    {
                        info.articulations[v] = true;
                    }
                    if (parent == v && children > 1)
                    {
                        info.articulations[v] = true;
                    }
                }
                if (e.destination != parent)
                {
                    info.low[v] = Math.Min(info.low[v], info.low[next]);
                }
            }
        }
        public ActionResult HelperList()
        {
            HelperData data = new HelperData();

            return(View(data.GetAll()));
        }
        public ActionResult HelperName(string term)
        {
            HelperData data = new HelperData();

            return(Json(data.GetNames(term), JsonRequestBehavior.AllowGet));
        }