Catbert4.Tests.Core.Helpers.CreateValidEntities.Unit C# (CSharp) Method

Unit() public static method

public static Unit ( int counter, bool populateAllFields = false ) : Unit
counter int
populateAllFields bool
return Catbert4.Core.Domain.Unit
        public static Unit Unit(int? counter, bool populateAllFields = false)
        {
            var rtValue = new Unit();
            rtValue.FullName = "FullName" + counter.Extra();
            rtValue.FisCode = "F" + counter.Extra();
            rtValue.School = new School();
            rtValue.ShortName = "ShortName" + counter.Extra();
            if (populateAllFields)
            {
                //rtValue.ShortName = "x".RepeatTimes(50);
                rtValue.PpsCode = counter.Extra();
            }
            return rtValue;
        }

Usage Example

コード例 #1
0
        public static void FakeUnits(int count, IRepository <Unit> repository, List <Unit> specificRecords)
        {
            var records = new List <Unit>();
            var specificRecordsCount = 0;

            if (specificRecords != null)
            {
                specificRecordsCount = specificRecords.Count;
                for (int i = 0; i < specificRecordsCount; i++)
                {
                    records.Add(specificRecords[i]);
                }
            }

            for (int i = 0; i < count; i++)
            {
                records.Add(CreateValidEntities.Unit(i + specificRecordsCount + 1));
            }

            var totalCount = records.Count;

            for (int i = 0; i < totalCount; i++)
            {
                records[i].SetIdTo(i + 1);
                int i1 = i;
                repository
                .Expect(a => a.GetNullableById(i1 + 1))
                .Return(records[i])
                .Repeat
                .Any();
                repository
                .Expect(a => a.GetById(i1 + 1))
                .Return(records[i])
                .Repeat
                .Any();
            }
            repository.Expect(a => a.GetNullableById(totalCount + 1)).Return(null).Repeat.Any();
            repository.Expect(a => a.Queryable).Return(records.AsQueryable()).Repeat.Any();
            repository.Expect(a => a.GetAll()).Return(records).Repeat.Any();
        }