예제 #1
0
        public bool Test(AcCommonObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "y":
            case "year":
                return(obj.Year.HasValue && value.Test(obj.Year.Value));

            case "new":
                return(value.Test(obj.IsNew));

            case "age":
                return(value.Test(obj.AgeInDays));

            case "date":
                return(value.Test(obj.CreationDateTime));

            case "errors":
            case "haserrors":
                return(value.Test(obj.HasErrors));

            case "changed":
                return(value.Test(obj.Changed));
            }

            return(AcObjectTester.Instance.Test(obj, key, value));
        }
예제 #2
0
        public bool Test(ServerPresetObject obj, string key, ITestEntry value)
        {
            //switch (key) {
            //}

            return(AcCommonObjectTester.Instance.Test(obj, key, value));
        }
예제 #3
0
        private void AddEntry(ITestEntry entry, String _file, String _method)
        {
            Factory.Instance.Create(out IResultKey key, Scenario, _file, _method);
            Factory.Instance.Create(out ITestMethodResult result);

            _results.GetOrAdd(key, result).TestEntries.Add(entry);
        }
예제 #4
0
        public bool Test(LapTimeWrapped obj, string key, ITestEntry value)
        {
            if (key == null)
            {
                return(value.Test(obj.Entry.CarId) || obj.Car != null && value.Test(obj.Car.DisplayName) ||
                       value.Test(obj.Entry.TrackId) || obj.Track != null && value.Test(obj.Track.Name));
            }

            switch (key)
            {
            case "time":
                value.Set(TestEntryFactories.TimeMinutes);
                return(value.Test(obj.Entry.LapTime));

            case "c":
            case "car":
                return(value.Test(obj.Car?.DisplayName) || value.Test(obj.Car?.Id));

            case "t":
            case "track":
                return(value.Test(obj.Track?.Name) || value.Test(obj.Track?.IdWithLayout));

            case "date":
                value.Set(DateTimeTestEntry.Factory);
                return(value.Test(obj.Entry.EntryDate));

            case "source":
            case "type":
                return(value.Test(obj.Entry.Source));
            }

            return(false);
        }
예제 #5
0
        public bool Test(CarSkinObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "skinname":
                return(value.Test(obj.Name));

            case "driver":
            case "drivername":
                return(value.Test(obj.DriverName));

            case "team":
            case "teamname":
                return(value.Test(obj.Team));

            case "n":
            case "number":
                return(value.Test(obj.SkinNumber));

            case "priority":
                return(value.Test(obj.Priority ?? 0));
            }

            return(AcJsonObjectTester.Instance.Test(obj, key, value));
        }
예제 #6
0
        public bool Test(TrackObjectBase obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(obj.Id) || value.Test(obj.LayoutName));

            case "city":
                return(value.Test(obj.City));

            case "geotags":
                return(value.Test(obj.GeoTags?.ToString()));

            case "len":
            case "length":
                value.Set(TestEntryFactories.DistanceKilometers);
                return(value.Test(obj.SpecsLengthValue / 1e3));

            case "width":
                value.Set(TestEntryFactories.DistanceMeters);
                return(value.Test(obj.SpecsWidth));

            case "pits":
            case "pitboxes":
                return(value.Test(obj.SpecsPitboxesValue));

            case "dd":
            case "driven":
            case "drivendistance":
                value.Set(TestEntryFactories.DistanceKilometers);
                return(value.Test(obj.TotalDrivenDistance / 1e3));
            }

            return(AcJsonObjectTester.Instance.Test(obj, key, value));
        }
예제 #7
0
        public bool Test(string carId, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(carId));

            case "l":
            case "len":
            case "length":
                return(value.Test(carId.Length));

            case "k":
            case "kunos": {
                return(value.Test(TestIfKunosUsingGuids(carId)));
            }

            case "a":
            case "age": {
                var directory = FileUtils.GetCarDirectory(_acRoot, carId);
                var age       = File.GetCreationTime(directory);
                return(value.Test((DateTime.Now - age).TotalDays));
            }

            case "n":
            case "new": {
                var directory = FileUtils.GetCarDirectory(_acRoot, carId);
                var age       = File.GetCreationTime(directory);
                return(value.Test((DateTime.Now - age).TotalDays < 7d));
            }

            default:
                return(false);
            }
        }
        public bool Test(AcObjectNew obj, string key, ITestEntry value)
        {
            switch (obj.GetType().Name)
            {
            case nameof(CarObject):
                return(CarObjectTester.Instance.Test((CarObject)obj, key, value));

            case nameof(TrackObject):
                return(TrackObjectTester.Instance.Test((TrackObject)obj, key, value));

            case nameof(TrackObjectBase):
            case nameof(TrackExtraLayoutObject):
                return(TrackObjectBaseTester.Instance.Test((TrackObjectBase)obj, key, value));

            case nameof(ShowroomObject):
                return(ShowroomObjectTester.Instance.Test((ShowroomObject)obj, key, value));

            case nameof(CarSkinObject):
                return(CarSkinObjectTester.Instance.Test((CarSkinObject)obj, key, value));

            case nameof(WeatherObject):
                return(WeatherObjectTester.Instance.Test((WeatherObject)obj, key, value));

            case nameof(CarSetupObject):
                return(CarSetupObjectTester.Instance.Test((CarSetupObject)obj, key, value));

            case nameof(ReplayObject):
                return(ReplayObjectTester.Instance.Test((ReplayObject)obj, key, value));

            default:
                return(AcObjectTester.Instance.Test(obj, key, value));
            }
        }
예제 #9
0
        public bool Test(TrackObjectBase obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(obj.Id) || value.Test(obj.LayoutName));

            case "city":
                return(value.Test(obj.City));

            case "geotags":
                return(value.Test(obj.GeoTags?.ToString()));

            case "len":
            case "length":
                return(value.Test(obj.SpecsLengthValue));

            case "width":
                return(value.Test(obj.SpecsWidth));

            case "pits":
            case "pitboxes":
                return(value.Test(obj.SpecsPitboxesValue));
            }

            return(AcJsonObjectTester.Instance.Test(obj, key, value));
        }
예제 #10
0
        public bool Test(AcJsonObjectNew obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "dlc":
                var dlc = obj.Dlc;
                return(value.Test(dlc?.Id ?? 0) || value.Test(dlc?.ShortName) || value.Test(dlc?.DisplayName));

            case "desc":
            case "description":
                return(value.Test(obj.Description));

            case "c":
            case "country":
                return(value.Test(obj.Country));

            case "t":
            case "tag":
                return(obj.Tags.Any(value.Test));

            case "version":
                return(value.Test(obj.Version));

            case "url":
                return(value.Test(obj.Url));
            }

            return(AcCommonObjectTester.Instance.Test(obj, key, value));
        }
예제 #11
0
        public bool Test(string[] obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(string.Join(", ", obj)));

            case "len":
                return(value.Test(obj.Length));

            case "empty":
                return(value.Test(obj.Length == 0));

            case "f":
                return(value.Test(obj.ElementAtOrDefault(0)));

            case "s":
                return(value.Test(obj.ElementAtOrDefault(1)));

            case "c":
                return(obj.Any(value.Test));
            }

            return(false);
        }
예제 #12
0
        public bool Test(CarObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "b":
            case "brand":
                return(value.Test(obj.Brand));

            case "newbrand":
                if (_list == null)
                {
                    _list = FilesStorage.Instance.GetContentFiles(ContentCategory.BrandBadges).Select(x => x.Name).ToList();
                }
                return(value.Test(!_list.Contains(obj.Brand)));

            case "class":
                return(value.Test(obj.CarClass));

            case "parent":
                return(value.Test(obj.Parent?.DisplayName));

            case "dd":
            case "driven":
            case "drivendistance":
                return(value.Test(obj.TotalDrivenDistance));

            case "topspeedachieved":
                return(value.Test(obj.MaxSpeedAchieved));

            case "bhp":
            case "power":
                return(value.Test(obj.SpecsBhp));

            case "torque":
                return(value.Test(obj.SpecsTorque));

            case "weight":
            case "mass":
                return(value.Test(obj.SpecsWeight));

            case "acceleration":
                return(value.Test(obj.SpecsAcceleration));

            case "speed":
            case "topspeed":
                return(value.Test(obj.SpecsTopSpeed));

            case "maxrpm":
                return(value.Test(obj.GetRpmMaxValue()));

            case "pw":
            case "pwratio":
                return(value.Test(obj.GetSpecsPwRatioValue()));

            case "skins":
                return(value.Test(obj.SkinsEnabledWrappersList?.Count ?? 0));
            }

            return(AcJsonObjectTester.Instance.Test(obj, key, value));
        }
예제 #13
0
        internal Entry(ITestEntry entry)
        {
            Throw.If.Object.IsNull(entry, nameof(entry));

            EntryType   = entry.EntryType;
            Instruction = entry.Instruction;
            Message     = entry.Message;
        }
예제 #14
0
        void FromResultThrows(Boolean result, String instruction, String message, String paramName)
        {
            ITestEntry entry = default;

            TestX.If.Action.ThrowsException(() => entry = TestEntry.FromResult(result, instruction, message), out ArgumentException argEx);
            TestX.If.Value.IsEqual(argEx.ParamName, paramName);
            TestX.If.Object.IsNull(entry);
        }
예제 #15
0
        void ConstructorThrows(EntryTypes type, String instruction, String message, String paramName)
        {
            ITestEntry entry = default;

            TestX.If.Action.ThrowsException(() => entry = new TestEntry(type, instruction, message), out ArgumentException argEx);
            TestX.If.Value.IsEqual(argEx.ParamName, paramName);
            TestX.If.Object.IsNull(entry);
        }
예제 #16
0
        void FromErrorThrows(String message, String paramName)
        {
            ITestEntry entry = default;

            TestX.If.Action.ThrowsException(() => entry = TestEntry.FromError(message), out ArgumentException argEx);
            TestX.If.Value.IsEqual(argEx.ParamName, paramName);
            TestX.If.Object.IsNull(entry);
        }
예제 #17
0
 public void Set(ITestEntryFactory factory)
 {
     if (ReferenceEquals(_overrideFactoryType, factory))
     {
         return;
     }
     _overrideFactoryType = factory;
     _override            = factory?.Create(_op, _originalValue);
 }
예제 #18
0
        public bool Test(CarSetupObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "track":
                return(value.Test(obj.Track?.Id) || value.Test(obj.Track?.Name));
            }

            return(AcCommonObjectTester.Instance.Test(obj, key, value));
        }
예제 #19
0
        public bool Test(TrackObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "layouts":
                return(value.Test(obj.MultiLayouts?.Count ?? 1));
            }

            return(TrackObjectBaseTester.Instance.Test(obj, key, value));
        }
예제 #20
0
        public bool Test(AcObjectNew obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(obj.Id) || value.Test(obj.Name));

            case "id":
                return(value.Test(obj.Id));

            case "name":
                return(value.Test(obj.Name));

            case "enabled":
                return(value.Test(obj.Enabled));

            case "rate":
            case "rated":
            case "rating":
                return(value.Test(obj.Rating ?? 0d));

            case "note":
            case "notes":
                return(value.Test(obj.Notes));

            case "fav":
            case "favorite":
            case "favourite":
            case "favorited":
            case "favourited":
                return(value.Test(obj.IsFavourite));

            case "new":
                return(value.Test(obj.IsNew));

            case "age":
                value.Set(TestEntryFactories.TimeDays);
                return(value.Test(obj.Age));

            case "date":
                value.Set(DateTimeTestEntry.Factory);
                return(value.Test(obj.CreationDateTime));

            case "a":
            case "author":
                return(value.Test((obj as IAcObjectAuthorInformation)?.Author));

            case "k":
            case "kunos":
                return(value.Test((obj as IAcObjectAuthorInformation)?.Author == AcCommonObject.AuthorKunos));

            default:
                return(false);
            }
        }
예제 #21
0
        void Constructor(EntryTypes type, String instruction, String message, EntryTypes expected_type, String expected_instruction, String expected_message)
        {
            ITestEntry entry = default;

            TestX.IfNot.Action.ThrowsException(() => entry = new TestEntry(type, instruction, message), out Exception ex);

            TestX.IfNot.Object.IsNull(entry);
            TestX.If.Value.IsEqual(entry.EntryType, expected_type);
            TestX.If.Value.IsEqual(entry.Instruction, expected_instruction);
            TestX.If.Value.IsEqual(entry.Message, expected_message);
        }
예제 #22
0
        void FromResult(Boolean result, String instruction, String message, EntryTypes expected_type, String expected_instruction, String expected_message)
        {
            ITestEntry entry = default;

            TestX.IfNot.Action.ThrowsException(() => entry = TestEntry.FromResult(result, instruction, message), out Exception ex);

            TestX.IfNot.Object.IsNull(entry);
            TestX.If.Value.IsEqual(entry.EntryType, expected_type);
            TestX.If.Value.IsEqual(entry.Instruction, expected_instruction);
            TestX.If.Value.IsEqual(entry.Message, expected_message);
        }
예제 #23
0
            public bool Test(SessionStats obj, string key, ITestEntry value)
            {
                switch (key)
                {
                case null:
                    if (value.Test(obj.CarId) || value.Test(obj.TrackId))
                    {
                        return(true);
                    }

                    var track = obj.TrackId == null ? null : TracksManager.Instance.GetLayoutById(obj.TrackId);
                    if (track != null && value.Test(track.Name))
                    {
                        return(true);
                    }

                    var car = obj.CarId == null ? null : CarsManager.Instance.GetById(obj.CarId);
                    if (car != null && value.Test(car.DisplayName))
                    {
                        return(true);
                    }

                    return(false);

                case "d":
                case "duration":
                case "time":
                    return(value.Test(obj.Time));

                case "date":
                    return(value.Test(obj.StartedAt));

                case "len":
                case "length":
                case "distance":
                    return(value.Test(obj.Distance));

                case "speed":
                case "average":
                case "averagespeed":
                case "avgspeed":
                    return(value.Test(obj.MaxSpeed));

                case "max":
                case "maxspeed":
                case "topspeed":
                    return(value.Test(obj.MaxSpeed));

                default:
                    return(false);
                }
            }
예제 #24
0
        /// <summary>
        /// Appends <paramref name="data"/> to the <see cref="Payload"/> <see cref="MemoryStream"/>.
        /// </summary>
        /// <param name="data">The data object.</param>
        /// <returns>The current <see cref="IMessage"/>.</returns>
        public IMessage Append(ITestEntry data)
        {
            Append(data.EntryType);

            if (data.EntryType == EntryTypes.ResultOk || data.EntryType == EntryTypes.ResultFail)
            {
                Append(data.Instruction);
            }

            Append(data.Message);

            return(this);
        }
예제 #25
0
        public bool Test(ShowroomObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "hassound":
                return(value.Test(obj.HasSound));

            case "sound":
                return(value.Test(obj.SoundEnabled));
            }

            return(AcJsonObjectTester.Instance.Test(obj, key, value));
        }
예제 #26
0
        public bool Test(TyresEntry obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(obj.DisplayName) || value.Test(obj.Name));

            case "n":
            case "name":
                return(value.Test(obj.Name));

            case "p":
            case "params":
                return(value.Test(obj.DisplayParams));

            case "profile":
                return(value.Test(obj.DisplayProfile));

            case "radius":
            case "rimradius":
                return(value.Test(obj.DisplayRimRadius));

            case "width":
                return(value.Test(obj.DisplayWidth));

            case "a":
            case "g":
            case "grade":
                return(value.Test(obj.AppropriateLevelFront.ToString()) || value.Test(obj.AppropriateLevelRear.ToString()));

            case "fa":
            case "fg":
            case "fgrade":
                return(value.Test(obj.AppropriateLevelFront.ToString()));

            case "ra":
            case "rg":
            case "rgrade":
                return(value.Test(obj.AppropriateLevelRear.ToString()));

            case "car":
                return(value.Test(obj.SourceCarId) || value.Test(obj.Source?.DisplayName));

            case "v":
            case "ver":
            case "version":
                return(value.Test(obj.Version));
            }

            return(false);
        }
예제 #27
0
        private static bool TestNode([NotNull] ITestEntry entry, [CanBeNull] Kn5Node node)
        {
            switch (entry)
            {
            case DefinitionTestEntry definitionEntry:
                return(definitionEntry.Test(node));

            case ListTestEntry listEntry:
                return(listEntry.Test(node));

            default:
                return(entry.Test(node?.Name));
            }
        }
예제 #28
0
        public bool Test(TrackObject obj, string key, ITestEntry value)
        {
            var multiLayouts = obj.MultiLayouts;

            switch (key)
            {
            case "layouts":
                return(value.Test(multiLayouts?.Count ?? 1));
            }

            return(multiLayouts?.Count > 1
                    ? multiLayouts.Any(x => TrackObjectBaseTester.Instance.Test(x, key, value))
                    : TrackObjectBaseTester.Instance.Test(obj, key, value));
        }
예제 #29
0
        public bool Test(string carId, string key, ITestEntry value)
        {
            switch (key)
            {
            case null:
                return(value.Test(carId));

            case "l":
            case "len":
            case "length":
                return(value.Test(carId.Length));
            }

            return(false);
        }
예제 #30
0
        public bool Test(WeatherObject obj, string key, ITestEntry value)
        {
            switch (key)
            {
            case "lights":
            case "carlights":
                return(value.Test(obj.ForceCarLights));

            case "temperature":
            case "temperaturecoeff":
            case "temperaturecoefficient":
                return(value.Test(obj.TemperatureCoefficient));
            }

            return(AcCommonObjectTester.Instance.Test(obj, key, value));
        }