コード例 #1
0
        public void MoveFileTest01()
        {
            var file    = RandomData.GenerateFile(Path.Combine(Environment.GetEnvironmentVariable(EnvironmentKey.TEMP.ToString()), $"{RandomData.GenerateKey()}.test"));
            var newFile = Path.Combine(Path.Combine(_tempPath.ToString(), $"{RandomData.GenerateKey()}.moved"));

            FileHelper.MoveFile(file, newFile, FileMoveOptions.ReplaceExisting);
        }
コード例 #2
0
        public void PropertiesToStringTest()
        {
            var personRecord = RandomData.GeneratePersonRecordCollection(1).First();

            var propertiesTest = new PropertiesTest
            {
                Id           = RandomData.GenerateKey(),
                PersonProper = RandomData.GenerateRefPerson <PersonProper>(),
                PersonRecord = RandomData.GeneratePersonRecordCollection(1).First(),
                Today        = DateTimeOffset.Now,
                ClosedOn     = DateTimeOffset.Now,
            };

            var result = personRecord.PropertiesToString(
                header: "PersonRecord",
                keyValueSeparator: ':',
                sequenceSeparator: ", ",
                ignoreNulls: true);

            Assert.IsTrue(result.Length > 1300);
            Assert.IsTrue(result.Contains("Addresses"));
            PrintResult(result, nameof(this.PropertiesToStringTest));

            result = propertiesTest.PropertiesToString(
                header: "PersonRecord",
                keyValueSeparator: ':',
                sequenceSeparator: ", ",
                ignoreNulls: true,
                includeMemberName: false);

            Assert.IsTrue(result.Length > 1300);
            Assert.IsTrue(result.Contains("Addresses"));
            PrintResult(result, nameof(this.PropertiesToStringTest));

            var person = RandomData.GenerateRefPerson <PersonProper>();

            result = person.PropertiesToString(header: person.Id);

            Assert.IsTrue(result.Length > 500);
            Assert.IsTrue(result.Contains("Address1"));
            PrintResult(result, nameof(this.PropertiesToStringTest));

            var coordinate = RandomData.GenerateCoordinate <CoordinateProper>();

            result = coordinate.PropertiesToString();

            Assert.IsTrue(result.Length > 50);
            Assert.IsTrue(result.Contains("X"));
            PrintResult(result, nameof(this.PropertiesToStringTest));

            var personCollection = RandomData.GeneratePersonRecordCollection(5);

            result = personCollection.PropertiesToString();
            Assert.IsTrue(result.Contains("LastName"));
            Assert.IsTrue(result.Length > 6000);
        }
コード例 #3
0
        public void AddItemsToCacheTest()
        {
            var cache = InMemoryCache.Instance;

            for (var count = 0; count < TestCount; count++)
            {
                cache.AddCacheItem <int>(key: RandomData.GenerateKey(), item: RandomData.GenerateInteger(count, 1000000));
            }

            Assert.IsTrue(cache.Count == TestCount);
        }
コード例 #4
0
        public void AddItemsToCache()
        {
            var cache = InMemoryCache.Instance;

            for (int i = 0; i < _testCount; i++)
            {
                cache.AddCacheItem <int>(RandomData.GenerateKey(), RandomData.GenerateInteger(i, 1000000));
            }

            Assert.IsTrue(cache.Count == _testCount);
        }
コード例 #5
0
        public override void Setup()
        {
            base.Setup();


            var list = new Dictionary <string, string>(this._collectionCount);

            for (var i = 0; i < this._collectionCount; i++)
            {
                list.Add(RandomData.GenerateKey(), RandomData.GenerateKey());
            }

            this._people = RandomData.GeneratePersonRefCollection <PersonProper>(this._collectionCount).ToList();
        }
コード例 #6
0
        public void PropertiesToDictionaryTest()
        {
            var personProper = RandomData.GeneratePersonRecordCollection(1).First();

            var propertiesTest = new PropertiesTest
            {
                Id           = RandomData.GenerateKey(),
                PersonProper = RandomData.GenerateRefPerson <PersonProper>(),
                PersonRecord = RandomData.GeneratePersonRecordCollection(1).First(),
                Today        = DateTime.Now
            };

            var result = personProper.PropertiesToDictionary(memberName: $"Person-{personProper.Id}", ignoreNulls: true);

            Assert.IsTrue(result.FastCount() > 1);

            result = propertiesTest.PropertiesToDictionary(
                memberName: $"TestPerson-{personProper.Id}",
                ignoreNulls: true);

            Assert.IsTrue(result.FastCount() > 1);
        }
コード例 #7
0
        public void GenerateKeyTest()
        {
            var stringValue = RandomData.GenerateKey();

            Assert.IsNotNull(stringValue);
        }
コード例 #8
0
        public void CopyAndMoveDirectoryTest()
        {
            var sourcePath      = Path.Combine(_tempPath.FullName, $"{nameof(this.CopyAndMoveDirectoryTest)}{RandomData.GenerateKey()}");
            var destinationPath = Path.Combine(_tempPath.FullName, nameof(this.CopyAndMoveDirectoryTest));

            RandomData.GenerateFiles(sourcePath, 100, 100);

            var folderToCopy = new DirectoryInfo(sourcePath);

            try
            {
                DirectoryHelper.CopyDirectory(folderToCopy.FullName, _tempPath.FullName, false);
                DirectoryHelper.MoveDirectory(folderToCopy.FullName, destinationPath, 2);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                DirectoryHelper.DeleteDirectory(destinationPath);
            }
        }