Пример #1
0
        protected void getListFromRepository <TDetail, TData, TRepository>(
            object obj, string name, Action <TData> setId, Func <TData, TDetail> toObject)

            where TRepository : IRepository <TDetail>
        {
            var t = isReadOnlyProperty(obj, name) as IReadOnlyList <TDetail>;

            Assert.IsNotNull(t);
            Assert.AreEqual(0, t.Count);
            var values      = GetRepository.Instance <TRepository>();
            var valuesCount = GetRandom.UInt8(10, 20);

            for (var i = 0; i < valuesCount; i++)
            {
                var d = GetRandom.Object <TData>();
                if (i % 4 == 0)
                {
                    setId(d);
                }
                values.Add(toObject(d)).GetAwaiter();
            }

            t = isReadOnlyProperty(obj, name) as IReadOnlyList <TDetail>;
            Assert.AreEqual((int)Math.Ceiling(valuesCount / 4.0), t?.Count);
        }
Пример #2
0
        protected void getFromRepository <TData, TObject, TRepository>(
            TData d, Func <TData> getData, Func <TData, TObject> toObject)

            where TData : UniqueEntityData, new()
            where TObject : IEntity <TData>
            where TRepository : IRepository <TObject>
        {
            GetRepository.Instance <TRepository>().Add(toObject(d)).GetAwaiter();
            arePropertiesEqual(d, getData());
        }
Пример #3
0
        protected void getFromRepository <TData, TObject, TRepository>(string id, Func <TData> getData,
                                                                       Func <TData, TObject> toObject)

            where TData : UniqueEntityData, new()
            where TObject : IUniqueEntity <TData>
            where TRepository : IRepository <TObject>
        {
            var d = GetRandom.Object <TData>();

            GetRepository.Instance <TRepository>().Add(toObject(d)).GetAwaiter();
            Assert.IsNotNull(getData());
            arePropertiesEqual(getData(), new TData(), "Id");
            d.Id = id;
            GetRepository.Instance <TRepository>().Add(toObject(d)).GetAwaiter();
            arePropertiesEqual(d, getData());
        }
Пример #4
0
 public void InstanceTest() => Assert.IsNull(GetRepository.Instance <IAirportsRepository>());