コード例 #1
1
        /// <summary>
        /// Perform a Quick Find on a small text file.
        /// </summary>
        /// <param name="unionFind">The union find to be tested.</param>
        internal static void CommonUnionFindTiny(IUnionFind unionFind)
        {
            using (In input = new In("Algs4-Data\\TinyUF.txt"))
             {
            int initialComponentCount = input.ReadInt();
            unionFind.IsolateComponents(initialComponentCount);
            while (!input.IsEmpty())
            {
               int siteP = input.ReadInt();
               int siteQ = input.ReadInt();
               if (unionFind.Connected(siteP, siteQ))
               {
                  continue;
               }

               unionFind.Union(siteP, siteQ);
            }
             }

             Assert.AreEqual(2, unionFind.Count);
        }
コード例 #2
0
        public void BinarySearchTiny()
        {
            int[] expected = { 5, -1, 0, -1, 4, 5, 15, 14, 1, 0, 9, 13, -1, 10, 15, 13, 13, 12 };
             int[] whiteList;

             // read the integers from a file and sort them
             using (In inWhiteList = new In("Algs4-Data\\TinyW.txt"))
             {
            whiteList = inWhiteList.ReadAllInts();
             }

             Array.Sort(whiteList);

             // read integer keys from a file; search in whitelist
             using (In inKeys = new In("Algs4-Data\\TinyT.txt"))
             {
            int expectedIndex = 0;
            while (!inKeys.IsEmpty() && expected.Length > expectedIndex)
            {
               int key = inKeys.ReadInt();
               int position = BinarySearch.Rank(key, whiteList);
               Assert.AreEqual(expected[expectedIndex++], position);
            }
             }
        }
コード例 #3
0
 public override DbParameter GetParameter(In parIn, bool isBulk) {
     var par = GetParameter();
     if (parIn == null) {
         return par;
     }
     return SetDataParameterType(parIn, isBulk, par);
 }
コード例 #4
0
        /// <summary>
        /// Common portion of file input UnionFind tests.
        /// </summary>
        /// <param name="streamName">The name for the input stream.</param>
        /// <param name="unionFind">The union find to be tested.</param>
        /// <returns>The Union Find structure.</returns>
        public static IUnionFind UnionFindCommon(string streamName, IUnionFind unionFind)
        {
            if (null == streamName)
             {
            throw new ArgumentNullException("streamName");
             }

             if (null == unionFind)
             {
            throw new ArgumentNullException("unionFind");
             }

             using (In input = new In(streamName))
             {
            int initialComponentCount = input.ReadInt();
            unionFind.IsolateComponents(initialComponentCount);
            while (!input.IsEmpty())
            {
               int siteP = input.ReadInt();
               int siteQ = input.ReadInt();
               if (unionFind.Connected(siteP, siteQ))
               {
                  continue;
               }

               unionFind.Union(siteP, siteQ);
            }

            return unionFind;
             }
        }
コード例 #5
0
ファイル: SelectBuilder.cs プロジェクト: SharpTools/sharpdata
		public SelectBuilder(Dialect dialect, string[] tables, string[] columns) {
			_dialect = dialect;
			_tables = tables;
			_columns = columns;

			Parameters = new In[0];
		}
コード例 #6
0
 public void ReadAllFromUrl()
 {
     using (In inObject = new In(UrlName))
      {
     string s = inObject.ReadAll();
     Assert.AreEqual(InUnitTests.InTest, s);
      }
 }
コード例 #7
0
 public void ReadCharFromFile()
 {
     using (In inObject = new In("InTest.txt"))
      {
     int expectedIndex = 0;
     while (!inObject.IsEmpty())
     {
        char c = inObject.ReadChar();
        Assert.IsTrue(expectedIndex < InUnitTests.InTestChars.Length);
        Assert.AreEqual(InUnitTests.InTestChars[expectedIndex++], c);
     }
      }
 }
コード例 #8
0
    /**/ public static void main(string[] strarr)
    {
        In i = new In(strarr[0]);
        EdgeWeightedGraph ewg        = new EdgeWeightedGraph(i);
        BoruvkaMST        boruvkaMST = new BoruvkaMST(ewg);
        Iterator          iterator   = boruvkaMST.edges().iterator();

        while (iterator.hasNext())
        {
            Edge obj = (Edge)iterator.next();
            StdOut.println(obj);
        }
        StdOut.printf("%.5f\n", new object[]
        {
            java.lang.Double.valueOf(boruvkaMST.weight())
        });
    }
コード例 #9
0
        public void ShouldCheckUpdateWhenEmailChanged()
        {
            @"
				Given bugzilla profile created
					And set of Users set to storage:
					|id|login|email|
					|1|user1|[email protected]|
					|2|user2|[email protected]|
				When handled UserUpdatedMessage message with user id 2, login 'user2' and changed email '*****@*****.**'
				Then users storage should contain 4 items
					And users storage should contain following items:
					|id|login|email|
					|1|user1|[email protected]|
					|2|user2|[email protected]|
			"
            .Execute(In.Context <BugSyncActionSteps>().And <UserChangedHandlerSpecs>());
        }
コード例 #10
0
        public void ShouldUpdateMappingOnEntityStateUpdated()
        {
            @"
				Given bugzilla profile for project 1 with process 12 created
					And following states created in TargetProcess:
						|id|name|
						|1|Open|
					And profile has following states mapping:
						|key|value|
						|Open|{Id:1, Name:""Open""}|
				When handled EntityStateUpdatedMessage message with entity state id 1, process id 12, name 'New', entityTypeName 'Tp.BusinessObjects.Bug'
				Then states mapping should be updated as following:
						|key|value|
						|Open|{Id:1, Name:""New""}|
			"
            .Execute(In.Context <BugSyncActionSteps>().And <EntityStateChangedHandlerSpecs>().And <EntityStateMappingSpecs>());
        }
コード例 #11
0
ファイル: 1320181.cs プロジェクト: qifanyyy/CLCDSA
    static int Int()
    {
        var n = 0;

        while (true)
        {
            var c = In.Read() - '0';
            if (0 <= c)
            {
                n = 10 * n + c;
            }
            else
            {
                return(n);
            }
        }
    }
コード例 #12
0
        public void ShouldReimportBugsIfTransportErrorOccuredOnGettingBugIds()
        {
            @"
				Given bugzilla profile created 
					And bugzilla contains bug 1 and name 'bug1' created on '2011-07-14 10:59:17'
					And bugzilla contains bug 2 and name 'bug2' created on '2011-07-14 10:59:17'
					And bugzilla contains bug 3 and name 'bug3' created on '2011-07-14 10:59:17'
					And chunk size is 1
					And last synchronization date is '2011-07-13 10:59:17'
				When transport error occured on getting bug ids during synchronization
					And last synchronization date is '2011-07-15 10:59:17'
					And synchronizing bugzilla bugs
				Then 3 bugs should be created in TargetProcess
					And bugs with following names should be created in TargetProcess: bug1, bug2, bug3
			"
            .Execute(In.Context <BugSyncActionSteps>().And <BugSyncSpecs>().And <ReimportFailedOnGettingIdsSpecs>());
        }
コード例 #13
0
        public void ShouldClearCommentOfInvalidCharacters()
        {
            @"
				Given user 'Lansie' with email '*****@*****.**' created in TargetProcess
					And user 'Dowson' with email '*****@*****.**' created in TargetProcess

					And bugzilla profile for project 1 created
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					And bug 1 has comment with invalid char at the end 'comment 1' created by '*****@*****.**'
				When synchronizing bugzilla bugs
				Then bugs with following names should be created in TargetProcess: bug1
					And bug in TargetProcess with name 'bug1' should have 1 comments
					And bug in TargetProcess with name 'bug1' should have comment 'comment&nbsp;1' created by 'Lansie'
			"
            .Execute(In.Context <BugSyncActionSteps>().And <CommentsFromBugzillaSyncSpecs>());
        }
コード例 #14
0
ファイル: nFactory.cs プロジェクト: JustinBritt/HM.HM5.A.E.O
        public In Create(
            ImmutableList <InParameterElement> value)
        {
            In parameter = null;

            try
            {
                parameter = new n(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(parameter);
        }
コード例 #15
0
        public void ShouldNotTryToImportDeletedAttachments()
        {
            @"
				Given bugzilla profile for project 1 created
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					And bug 1 has attachment 'file1' with content 'abcdefj' created on '2010-10-10 13:13'
					And bug 1 has deleted attachment 'file2' created on '2010-10-10 13:13'
					And synchronizing bugzilla bugs
				When synchronizing bugzilla bugs
				Then bugs with following names should be created in TargetProcess: bug1
					And bug in TargetProcess with name 'bug1' should have 1 attachments
					And bug in TargetProcess with name 'bug1' should have attachment 'file1' with content 'abcdefj' created on '2010-10-10 13:13'
					And no attachments should present on disk
			"
            .Execute(In.Context <BugSyncActionSteps>().And <AttachmentSyncSpecs>());
        }
コード例 #16
0
ファイル: OracleOdpProvider.cs プロジェクト: zhouzu/sharpdata
        private DbParameter SetDataParameterType(In parIn, bool isBulk, DbParameter par)
        {
            var value = parIn.Value;

            if (isBulk)
            {
                if (value is ICollection collParam && collParam.Count != 0)
                {
                    var enumerator = collParam.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        if ((value = enumerator.Current) != null)
                        {
                            break;
                        }
                    }
                }
            }
            if (value == null)
            {
                value = "";
            }
            if (parIn.DbType.HasValue)
            {
                par.DbType = parIn.DbType.Value;
                return(par);
            }

            var type = GenericDbTypeMap.GetDbType(value.GetType());

            if (type == DbType.Boolean)
            {
                type      = DbType.Int32;
                par.Value = (bool)value ? 1 : 0;
            }
            else if (type == DbType.Date)
            {
                ReflectionCache.PropParameterDbType.SetValue(par, ReflectionCache.DbTypeDate, null);
            }
            else if (type == DbType.Binary)
            {
                ReflectionCache.PropParameterDbType.SetValue(par, ReflectionCache.DbTypeBlob, null);
            }
            par.DbType = type;
            return(par);
        }
コード例 #17
0
        public void ShouldImportAttachmentsOnBugCreated()
        {
            @"
				Given bugzilla profile for project 1 created
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					
					And bug 1 has attachment 'file1' with content 'abcdefj' created on '2010-10-10 13:13'
					And bug 1 has attachment 'file2' with content '123456' created on '2010-10-10 13:13'
				When synchronizing bugzilla bugs
				Then bugs with following names should be created in TargetProcess: bug1
					And bug in TargetProcess with name 'bug1' should have 2 attachments
					And bug in TargetProcess with name 'bug1' should have attachment 'file1' with content 'abcdefj' created on '2010-10-10 13:13'
					And bug in TargetProcess with name 'bug1' should have attachment 'file2' with content '123456' created on '2010-10-10 13:13'
			"
            .Execute(In.Context <BugSyncActionSteps>().And <AttachmentSyncSpecs>());
        }
コード例 #18
0
        public void ShouldMigrateBinderProfilesToEachPopProfile()
        {
            @"Given project 'Pr1' created
					And project 'Pr2' created
					And account name is 'Account'
					And project 'Pr1' IsInboundMailEnabled email setting is set to true
					And project 'Pr1' InboundMailCreateRequests email setting is set to true
					And project 'Pr2' IsInboundMailEnabled email setting is set to false
					And bind email plugin has active profile 'Profile1'
					And bind email plugin profile 'Profile1' has key 'Pr2' and value 'Jira1'
				When email settings from Target Process converted to e-mail plugin profile
				Then plugin 'Project Email Integration' should have account 'Account'
					And 1 plugin profile should be created
					And email plugin profile should contains rule : 'when subject contains 'Jira1' then attach to project ProjectId and create request in project ProjectId' where ProjectId is id of project 'Pr2'
					And email plugin profile should contains rule : 'then attach to project ProjectId' where ProjectId is id of project 'Pr1'"
            .Execute(In.Context <LegacyProfileConverterActionSteps>());
        }
コード例 #19
0
        public void ShouldSupportTpUserSpecifiedByEmail()
        {
            @"Given account name is 'Account'
					And profile name is 'ProfileName'
					And tp user with login 'tpuser1' and email '*****@*****.**'
					And tp user with login 'tpuser2' and email '*****@*****.**'
					And user mapping is:
					|subversion|targetprocess|
					|svnuser1|[email protected]|
					|svnuser2|[email protected]|
				When legacy subversion plugin profile from Target Process converted to new subversion plugin profile
				Then user mapping should be:
					|subversion|targetprocess|
					|svnuser1|tpuser1|
					|svnuser2|tpuser2|"
            .Execute(In.Context <LegacyProfileConverterActionSteps>());
        }
コード例 #20
0
        public void ShouldSkipRequesters()
        {
            @"Given account name is 'Account'
					And profile name is 'ProfileName'
					And requester 'requester' created
					And user 'tpuser' created
					And user mapping is:
					|subversion|targetprocess|
					|svnuser1|requester|
					|svnuser2|tpuser|
				When legacy subversion plugin profile from Target Process converted to new subversion plugin profile
				Then user mapping should be:
					|subversion|targetprocess|
					|svnuser2|tpuser|
					And 1 user snould be mapped"
            .Execute(In.Context <LegacyProfileConverterActionSteps>());
        }
コード例 #21
0
        /// <summary>
        /// Serialize to OpenAPI V3 document without using reference.
        /// </summary>
        public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
        {
            writer.WriteStartObject();

            // type
            writer.WriteProperty(OpenApiConstants.Type, Type.GetDisplayName());

            // description
            writer.WriteProperty(OpenApiConstants.Description, Description);

            switch (Type)
            {
            case SecuritySchemeType.ApiKey:
                // These properties apply to apiKey type only.
                // name
                // in
                writer.WriteProperty(OpenApiConstants.Name, Name);
                writer.WriteProperty(OpenApiConstants.In, In.GetDisplayName());
                break;

            case SecuritySchemeType.Http:
                // These properties apply to http type only.
                // scheme
                // bearerFormat
                writer.WriteProperty(OpenApiConstants.Scheme, Scheme);
                writer.WriteProperty(OpenApiConstants.BearerFormat, BearerFormat);
                break;

            case SecuritySchemeType.OAuth2:
                // This property apply to oauth2 type only.
                // flows
                writer.WriteOptionalObject(OpenApiConstants.Flows, Flows, (w, o) => o.SerializeAsV3(w));
                break;

            case SecuritySchemeType.OpenIdConnect:
                // This property apply to openIdConnect only.
                // openIdConnectUrl
                writer.WriteProperty(OpenApiConstants.OpenIdConnectUrl, OpenIdConnectUrl?.ToString());
                break;
            }

            // extensions
            writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);

            writer.WriteEndObject();
        }
コード例 #22
0
        private Out RequestToRemoteResponseSocket(In din)
        {
            try
            {
                //向远端Rep 服务器请求并获取数据
                using (var req = new RequestSocket(ResponseHostString)
                {
                    Options = { }
                })
                {
                    req.Options.Identity = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString("N"));

                    req.SendFrame(din.ToProtobuf());

                    return(req.ReceiveFrameBytes().FromProtobuf <Out>());

                    //if (req.TrySendFrame(TimeSpan.FromMilliseconds(200),din.ToProtobuf()))
                    //{
                    //    if (req.TryReceiveFrameBytes(DefaultTimeOuTimeSpan, out var responseBytes))
                    //        return responseBytes.FromProtobuf<Out>();
                    //    else
                    //    {
                    //        if (Logger.IsWarnEnabled)
                    //            Logger.Warn("request to remote TryReceive timeout");
                    //    }
                    //}
                    //else
                    //{
                    //    if (Logger.IsWarnEnabled)
                    //        Logger.Warn("request to remote TrySend timeout");
                    //}
                }
            }
            catch (Exception e)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error(e);
                }

                return(null);
            }

            return(null);
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: simple555a/DotNetAppDev
        private static async Task MainAsync()
        {
            File.WriteAllLines("secrets.txt", new[] { "Secret password: 12345" });
            await Out.WriteLineAsync("Enter in your script - type \"STOP\" to quit:").ConfigureAwait(false);

            var context = new ScriptingContext();
            var options = ScriptOptions.Default
                          .AddImports(
                typeof(ImmutableArrayExtensions).Namespace)
                          .AddReferences(
                typeof(ImmutableArrayExtensions).Assembly);

            while (true)
            {
                var code = await In.ReadLineAsync().ConfigureAwait(false);

                if (code == "STOP")
                {
                    break;
                }

                var script = CSharpScript.Create(
                    code, globalsType: typeof(ScriptingContext), options: options);
                var compilation = script.GetCompilation();
                var diagnostics = compilation.GetDiagnostics().Union(
                    VerifyCompilation(compilation)).ToImmutableArray();

                if (diagnostics.Length > 0)
                {
                    foreach (var diagnostic in diagnostics)
                    {
                        Out.WriteLine(diagnostic);
                    }
                }
                else
                {
                    var result = await CSharpScript.RunAsync(code, globals : context, options : options).ConfigureAwait(false);

                    if (result.ReturnValue != null)
                    {
                        await Out.WriteLineAsync($"\t{result.ReturnValue}").ConfigureAwait(false);
                    }
                }
            }
        }
コード例 #24
0
        public async Task <Result> Login(In <LoginIn> inData)
        {
            Result result = await VerifyLogin(inData.data);

            if (!result.result)
            {
                return(result);
            }
            DBHelper db   = new DBHelper();
            t_user   user = await UserDao.GetUser(db, inData.data.user_name);

            bool password_flag = VerifyCommon.VerifyPassword(user.id, user.salt, user.password, inData.data.password);

            if (!password_flag)
            {
                db.Close();
                result.msg = "用户名或密码错误";
                return(result);
            }

            LoginResult loginResult = new LoginResult
            {
                user_id         = user.id,
                department_name = await DepartmentDao.GetDepartmentName(db, user.department_id),
                position_name   = await PositionDao.GetPositionName(db, user.position_id),
                department_id   = user.department_id,
                position_id     = user.position_id,
                name            = user.real_name,
                token           = ConcealCommon.EncryptDES(user.id + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss:ms")),
                user_name       = user.user_name,
            };

            db.Close();

            await RedisHelper.Instance.SetStringKeyAsync($"user-multi-token:{loginResult.token}", loginResult, TimeSpan.FromHours(4));

            Result <LoginResult> result1 = new Result <LoginResult>
            {
                data   = loginResult,
                result = true,
                msg    = "登录成功"
            };

            return(result1);
        }
コード例 #25
0
        public void Run()
        {
            Console.WriteLine("Choose file:");     // Prompt
            Console.WriteLine("1 - tinyTale.txt"); // Prompt
            Console.WriteLine("or quit");          // Prompt

            var fileNumber = Console.ReadLine();
            var fieName    = string.Empty;

            switch (fileNumber)
            {
            case "1":
                fieName = "tinyTale.txt";
                break;

            case "quit":
                return;

            default:
                return;
            }


            var @in   = new In($"Files\\Searching\\{fieName}");
            var words = @in.ReadAllStrings();

            var inFilter = new In($"Files\\Searching\\list.txt");
            var filter   = inFilter.ReadAllStrings();

            //var list = words.Select(word => new StringComparable(word)).ToList();
            //var listComparable = list.Cast<IComparable>().ToList();
            //var arrayComparable = list.Cast<IComparable>().ToArray();
            //var listStrings = words.ToList();

            var blackFilter = new BlackFilter(filter);

            foreach (var word in words)
            {
                blackFilter.Filter(word);
            }



            Console.ReadLine();
        }
コード例 #26
0
        public void ShouldSkipUsersThatDoNotExistInTp()
        {
            @"Given account name is 'Account'
					And profile name is 'ProfileName'
					And user 'tpuser1' created
					And user 'tpuser3' created
					And user mapping is:
					|subversion|targetprocess|
					|svnuser1|tpuser1|
					|svnuser2|tpuser2|
					|svnuser3|tpuser3|
				When legacy subversion plugin profile from Target Process converted to new subversion plugin profile
				Then user mapping should be:
					|subversion|targetprocess|
					|svnuser1|tpuser1|
					|svnuser3|tpuser3|"
            .Execute(In.Context <LegacyProfileConverterActionSteps>());
        }
コード例 #27
0
        public void ShouldNotProcessBugThatWasJustUpdatedByProfile()
        {
            @"
				Given TargetProcess contains bug entity states for project 1 : 1-assigned,2-new
					And bugzilla contains bug statuses : assigned,new
					And bugzilla profile for project 1 created 
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					And bug 1 has status 'new'
					And synchronizing bugzilla bugs

					And bug 1 has status 'assigned'
				When synchronizing bugzilla bugs
				Then bug in TargetProcess with name 'bug1' should have state 'assigned'
					And bug 1 should not be updated in Bugzilla
			"
            .Execute(In.Context <BugSyncActionSteps>().And <BugSyncSpecs>().And <EntityStateSyncSpecs>());
        }
コード例 #28
0
        public void ShouldMigrateDataFromBindEmailToProjectPlugin()
        {
            @"Given project 'Pr' created
					And account name is 'Account'
					And project 'Pr' IsInboundMailEnabled email setting is set to true
					And bind email plugin has active profile 'Profile1'
					And bind email plugin profile 'Profile1' has key 'Pr' and value 'Jira1,Jira2'
					And bind email plugin has active profile 'Profile2'
					And bind email plugin profile 'Profile2' has key 'Pr' and value 'Jira4'
					And bind email plugin has inactive profile 'Profile3'
					And bind email plugin profile 'Profile3' has key 'Pr' and value 'Jira5'
				When email settings from Target Process converted to e-mail plugin profile
				Then plugin 'Project Email Integration' should have account 'Account'
					And 1 plugin profile should be created
					And email plugin profile should contains rule : 'when subject contains 'Jira1,Jira2,Jira4' then attach to project ProjectId' where ProjectId is id of project 'Pr'
					And email plugin profile should contains rule : 'then attach to project ProjectId' where ProjectId is id of project 'Pr'"
            .Execute(In.Context <LegacyProfileConverterActionSteps>());
        }
コード例 #29
0
        public void ShouldDoNothingIfCantMapTpStateToBzState()
        {
            @"
				Given TargetProcess contains bug entity states for project 1 : 1-open,2-done,3-invalid
					And bugzilla contains bug statuses : new,closed,done
					And bugzilla profile for project 1 created 
					And profile has following states mapping:
						|key|value|
						|new|{Id:1, Name:""open""}|
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					And bug 1 has status 'done'
					And synchronizing bugzilla bugs
				When bug 'bug1' entity state was updated in TargetProcess to 'invalid'
				Then bug 1 status in bugzilla should be 'done'
			"
            .Execute(In.Context <BugSyncActionSteps>().And <BugSyncSpecs>().And <EntityStateSyncSpecs>().And <EntityStateMappingSpecs>());
        }
コード例 #30
0
        public void PluginShouldUpdateTpEntitiesTest()
        {
            @"
				Given tfs profile 'TestProfile' created 
					And work items store contains entity with name 'userStory1' and description 'important user story' and type 'User Story'
                    And work items were synchronized
                    And user stories with following names should be created in TargetProcess: 'userStory1'
                    And user stories in TargetProcess with name 'userStory1' should have description 'important user story'
					And user stories in TargetProcess with name 'userStory1' should be in 'Test'
                    And work item 'userStory1' field 'Description' changed for 'description changed'
                    And work item 'userStory1' field 'Title' changed for 'userStory1changed'
                When synchronizing work items entities
				Then user story with name 'userStory1' is absent in TP
                    And user stories with following names should be created in TargetProcess: 'userStory1changed'
					And user stories in TargetProcess with name 'userStory1changed' should have description 'description changed'
					And user stories in TargetProcess with name 'userStory1changed' should be in 'Test'"
            .Execute(In.Context <WorkItemsActionSteps>());
        }
        public void ShouldNotImportDefaultComment()
        {
            string.Format(@"
				Given user 'Lansie' with email '*****@*****.**' created in TargetProcess

					And bugzilla profile for project 1 created
					And bugzilla contains bug with id 1
					And bug 1 has name 'bug1'
					And bug 1 has comment 'comment 1' created on '2010-10-10 13:13' by '*****@*****.**'
					And synchronizing bugzilla bugs

				When comment '{0}' for bug 'bug1' was created by 'Lansie' in TargetProcess

				Then bug 1 in bugzilla should have 1 comments
			"            , CommentConverter.StateIsChangedComment)
            .Execute(In.Context <BugSyncActionSteps>().And <BugSyncSpecs>().And <CommentsFromTargetProcessSyncSpecs>()
                     .And <CommentsFromBugzillaSyncSpecs>());
        }
コード例 #32
0
ファイル: Program.cs プロジェクト: TochaFh/FastConsole.Input
        static void Main(string[] args)
        {
            var opts = new SimpleInputOpt("Enter your age: ", "You must digit a valid number!\n");

            int   age    = In.ReadInt(opts).Value;
            float height = In.ReadFloat(opts.SetMsg("Enter your height: ")).Value;

            Out.Println($"You are {age} years old and your height is {height}m!\n");

            string[] words = In.ReadInput <string[]>(opts.SetMsg("Enter your favorite words: "), GetWords);

            Out.Println("\nYour favorite words are:");

            foreach (var word in words)
            {
                Out.Println("- " + word.I(Red));
            }
        }
コード例 #33
0
        /// <summary>
        /// Releases any resources used by this instance.
        /// </summary>
        public void Dispose()
        {
            //Check
            if (isDisposed)
            {
                return;
            }

            //Dispose
            ms.Dispose();
            Out.Dispose();
            In.Dispose();
            isDisposed = true;

            //Null
            ms     = null;
            buffer = null;
        }
コード例 #34
0
        public void ShouldMapUserUsingLoginIfEmailAndNameWereNotFound()
        {
            @"
				Given vcs history is:
					|commit|
					|{Author:""ValentinePalazkov""}|
					And unsaved plugin profile
					And target process users with logins, names and mails:
						|login|name|mail|
						|[email protected]|Valentpa|[email protected]|
						|ValentinePalazkov|ValentineMalkovich|[email protected]|				
				When automapping requested
				Then users should be mapped this way:
					|svnuser|tpuser|
					|ValentinePalazkov|ValentineMalkovich|
"
            .Execute(In.Context <VcsPluginActionSteps>().And <CommandActionSteps>());
        }
コード例 #35
0
 public override void Activate()
 {
     for (int i = 0; i < In.Size.X; i++)
     {
         for (int j = 0; j < In.Size.Y; j++)
         {
             for (int z = 0; z < In.Size.Z; z++)
             {
                 float v = In.Get(i, j, z);
                 if (v < 0)
                 {
                     v = 0;
                 }
                 Out.Set(i, j, z, v);
             }
         }
     }
 }
コード例 #36
0
        public void ShouldDeleteRolesMappingIfRoleIsDeleted()
        {
            @"
				Given Role 'Developer' created in TargetProcess
					And Role 'QA Engineer' created in TargetProcess
					And bugzilla profile created
					And profile role mapping is the following:
						|key|value|
						|Assignee|Developer|
						|Reporter|QA Engineer|
				When role 'QA Engineer' has been removed in TargetProcess
				Then resulting mapping count should be equal to bugzilla roles count
					And resulting mapping is the following:
						|key|value|
						|Assignee|Developer|
			"
            .Execute(In.Context <BugSyncActionSteps>().And <AssignmentsFromBugzillaSyncSpecs>().And <RolesMappingSpecs>());
        }
コード例 #37
0
        public void ShouldDeleteMappingOnEntityStateDeleted()
        {
            @"
				Given bugzilla profile created
					And set severity with id 1 and name 'must' to storage
					And set severity with id 2 and name 'nice to have' to storage
					And profile has following severities mapping:
						|key|value|
						|must|{Id:1, Name:""must""}|
						|nice to have|{Id:2, Name:""nice to have""}|
				When handled SeverityDeletedMessage message with severity id 2
				Then severities mapping contains 1 items
					And severities mapping should be updated as following:
						|key|value|
						|must|{Id:1, Name:""must""}|
			"
            .Execute(In.Context <BugSyncActionSteps>().And <SeveritiesMappingSpecs>().And <SeverityChangedHandlerSpecs>());
        }
コード例 #38
0
        /// <summary>
        /// Sort a small text file.
        /// </summary>
        /// <param name="streamName">The name of the file to sort.</param>
        /// <param name="sortingAlgorithm">The algorithm to use for sorting.</param>
        /// <returns>The sorted items.</returns>
        public static string[] SortCommon(string streamName, ISortingAlgorithm sortingAlgorithm)
        {
            Contract.Ensures(null != Contract.Result<string[]>());
             if (null == sortingAlgorithm)
             {
            throw new ArgumentNullException("sortingAlgorithm");
             }

             string[] testItems;
             using (In inStream = new In(streamName))
             {
            testItems = inStream.ReadAllStrings();
             }

             if (null == testItems)
             {
            throw new InternalTestFailureException("No items to test");
             }

             sortingAlgorithm.Sort(testItems);
             return testItems;
        }
コード例 #39
0
        /// <summary>
        /// Test a queue using a stream (file) with strings and taking the minus sign
        /// as an indication to de-queue an item.
        /// </summary>
        /// <param name="streamName">The stream from where the input strings will be read.</param>
        /// <param name="queue">The queue to operate on.</param>
        /// <param name="expectedResults">The expected sequence of items removed by the minus signs.</param>
        /// <param name="expectedRemainder">
        /// The expected amount of items in the queue after all the removals have been processed
        /// </param>
        public static void StringPQTest(string streamName, PQCollection<string> queue, string[] expectedResults, int expectedRemainder)
        {
            Contract.Requires<ArgumentNullException>(queue != null, "queue");
             Contract.Requires<ArgumentNullException>(expectedResults != null, "expectedResults");
             string[] testItems;
             int expectedIndex = 0;
             using (In inStream = new In(streamName))
             {
            testItems = inStream.ReadAllStrings();
             }

             if (null == testItems)
             {
            throw new InternalTestFailureException("No items to test.");
             }

             foreach (string testItem in testItems)
             {
            if (0 != string.CompareOrdinal(testItem, "-"))
            {
               queue.Enqueue(testItem);
            }
            else if (1 > queue.Count)
            {
               throw new InternalTestFailureException("Queue underflow.");
            }
            else if (expectedResults.Length <= expectedIndex)
            {
               throw new InternalTestFailureException("Expected Results underflow.");
            }
            else
            {
               Assert.AreEqual(expectedResults[expectedIndex++], queue.Dequeue());
            }
             }

             Assert.AreEqual(expectedRemainder, queue.Count());
        }
コード例 #40
0
 public void ReadLineAbsoluteWindowsPath()
 {
     string currentDirectory = Directory.GetCurrentDirectory();
      string fullPath = Path.Combine(currentDirectory, "InTest.txt");
      using (In inObject = new In(fullPath))
      {
     int expectedIndex = 0;
     while (!inObject.IsEmpty())
     {
        string s = inObject.ReadLine();
        Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
        Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
     }
      }
 }
コード例 #41
0
ファイル: Save.cs プロジェクト: KylerM/Skylight
 /// <summary>
 /// Initializes a new instance of the <see cref="Save"/> class.
 /// </summary>
 /// <param name="in">
 /// The in.
 /// </param>
 public Save(In @in)
 {
     this._in = @in;
 }
コード例 #42
0
 public virtual IDbDataParameter GetParameter(In parameter, bool isBulk)
 {
     return GetParameter();
 }
コード例 #43
0
ファイル: RefreshShop.cs プロジェクト: KylerM/Skylight
 /// <summary>
 /// Initializes a new instance of the <see cref="RefreshShop"/> class.
 /// </summary>
 /// <param name="in">
 /// The in.
 /// </param>
 public RefreshShop(In @in)
 {
     this._in = @in;
 }
コード例 #44
0
        public void ReadLineFromRelativePath()
        {
            string relativeFile = string.Format(
            CultureInfo.InvariantCulture,
            "..\\{0}\\InTest.txt",
            Path.GetFileName(Directory.GetCurrentDirectory()));

             using (In inObject = new In(relativeFile))
             {
            int expectedIndex = 0;
            while (!inObject.IsEmpty())
            {
               string s = inObject.ReadLine();
               Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
               Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
            }
             }
        }
コード例 #45
0
ファイル: AXIMaster.cs プロジェクト: venusdharan/systemsharp
        /// <summary>
        /// Constructs an instance.
        /// </summary>
        /// <param name="numRegs">number of registers</param>
        /// <param name="slvDWidth">data width</param>
        public AXIMasterUserLogic(int numRegs, int slvDWidth)
        {
            NumRegs = numRegs;
            SLVDWidth = slvDWidth;
            SlaveAXIDataWidth = SLVDWidth;
            SlaveAXIAddrWidth = 32;
            AXIMinSize = "000001FF";
            UseWRSTRB = 0;
            DPhaseTimeout = 8;
            BaseAddr = "FFFFFFFF";
            HighAddr = "00000000";
            NumMem = 1;
            SLVAWidth = 32;
            UserSLVNumReg = NumRegs;
            MasterAXIAddrWidth = SlaveAXIAddrWidth;
            MasterAXIDataWidth = SlaveAXIDataWidth;
            MaxBurstLen = 16;
            NativeDataWidth = SlaveAXIDataWidth;
            LengthWidth = 12;
            AddrPipeDepth = 1;
            UserPorts = new List<UserPort>();

            _writeBits = new Out<StdLogic>[NumRegs, SLVDWidth];
            _readBits = new In<StdLogic>[NumRegs, SLVDWidth];
        }
コード例 #46
0
ファイル: Auth.cs プロジェクト: Sagu/BNet-DLS
 public static void HandlePacket(In packetId, BitReader bitReader)
 {
     switch (packetId)
     {
         case In.ProofRequest:
             GenerateProofRequest(bitReader);
             break;
         case In.AuthComplete:
             GenerateAuthComplete(bitReader);
             break;
         default:
             DeepLogic.Core.ErrorHandler.Log("BNet","debug",String.Format("App: Unhandled packet, {0}", (int)packetId));
             break;
     }
 }
コード例 #47
0
        /// <summary>
        /// Read multiple sorted streams and merge their contents in sorted order.
        /// </summary>
        /// <param name="streamNames">The stream names to read from.</param>
        /// <param name="priorityQueue">The Index Priority Queue to use for merging.</param>
        /// <param name="expectedItems">The expected results.</param>
        /// <remarks>
        /// This method expects each input stream to be sorted but does not verify it.
        /// If the inputs are unsorted the results will be incorrect.
        /// </remarks>
        public static void MergeMultiWay(string[] streamNames, IndexPQDictionary<string> priorityQueue, Queue<string> expectedItems)
        {
            In[] inputStream = new In[streamNames.Length];

             try
             {
            for (int i = 0; streamNames.Length > i; i++)
            {
               inputStream[i] = new In(streamNames[i]);
               priorityQueue.Enqueue(i, inputStream[i].ReadString());
            }

            // Extract and print min and read next from its stream.
            while (0 != priorityQueue.Count)
            {
               string actualItem = priorityQueue.PeekPriority();
               string expectedItem = expectedItems.Dequeue();
               Assert.AreEqual(expectedItem, actualItem);
               int i = priorityQueue.Dequeue();
               if (!inputStream[i].IsEmpty())
               {
                  priorityQueue.Enqueue(i, inputStream[i].ReadString());
               }
            }
             }
             finally
             {
            for (int i = 0; streamNames.Length > i; i++)
            {
               inputStream[i].Close();
            }
             }
        }
コード例 #48
0
        /// <summary>
        /// Constructs an instance.
        /// </summary>
        /// <param name="numRegs">number of registers</param>
        /// <param name="slvDWidth">data width</param>
        public AXILiteSlaveUserLogic(int numRegs, int slvDWidth)
        {
            NumRegs = numRegs;
            SLVDWidth = slvDWidth;

            _writeBits = new Out<StdLogic>[NumRegs, SLVDWidth];
            _readBits = new In<StdLogic>[NumRegs, SLVDWidth];
        }
コード例 #49
0
 private IDbDataParameter SetDataParameterType(In parIn, bool isBulk, IDbDataParameter par)
 {
     var value = parIn.Value;
     if (isBulk) {
         var collParam = value as ICollection;
         if (collParam != null && collParam.Count != 0) {
             var enumerator = collParam.GetEnumerator();
             while (enumerator.MoveNext()) {
                 if ((value = enumerator.Current) != null) {
                     break;
                 }
             }
         }
     }
     if (value == null) {
         value = "";
     }
     par.DbType = DbTypeMapper.GetDbType(value.GetType());
     if (par.DbType == DbType.Binary) {
         ReflectionCache.PropParameterDbType.SetValue(par, ReflectionCache.DbTypeBlob, null);
     }
     return par;
 }
コード例 #50
0
 public void ReadStringFromUrl()
 {
     using (In inObject = new In(UrlName))
      {
     int expectedIndex = 0;
     while (!inObject.IsEmpty())
     {
        string s = inObject.ReadString();
        Assert.IsTrue(expectedIndex < InUnitTests.InTestWords.Length);
        Assert.AreEqual(InUnitTests.InTestWords[expectedIndex++], s);
     }
      }
 }
コード例 #51
0
ファイル: ALU.cs プロジェクト: venusdharan/systemsharp
 private IEnumerable<TAVerb> Do(ISignalSource<StdLogicVector> a, ISignalSource<StdLogicVector> b, 
     In<StdLogicVector> rs, ISignalSink<StdLogicVector> r)
 {
     if (_host.PipelineDepth == 0)
     {
         yield return Verb(ETVMode.Locked, 
             _host.A.Dual.Drive(a)
                 .Par(_host.B.Dual.Drive(b))
                 .Par(r.Comb.Connect(rs.AsSignalSource())));
     }
     else
     {
         yield return Verb(ETVMode.Locked, 
             _host.A.Dual.Drive(a)
                 .Par(_host.B.Dual.Drive(b)));
         for (int i = 1; i < _host.PipelineDepth; i++)
         {
             yield return Verb(ETVMode.Shared);
         }
         yield return Verb(ETVMode.Shared,
             r.Comb.Connect(rs.AsSignalSource()));
     }
 }
コード例 #52
0
 public void ReadLineFromCurrentDirectory()
 {
     using (In inObject = new In("./InTest.txt"))
      {
     while (!inObject.IsEmpty())
     {
        int expectedIndex = 0;
        while (!inObject.IsEmpty())
        {
           string s = inObject.ReadLine();
           Assert.IsTrue(expectedIndex < InUnitTests.InTestLines.Length);
           Assert.AreEqual(InUnitTests.InTestLines[expectedIndex++], s);
        }
     }
      }
 }
コード例 #53
0
ファイル: Show.cs プロジェクト: KylerM/Skylight
 /// <summary>
 /// Initializes a new instance of the <see cref="Show"/> class.
 /// </summary>
 /// <param name="in">
 /// The in.
 /// </param>
 public Show(In @in)
 {
     this._in = @in;
 }