示例#1
0
        public void GetEntityTypeByName()
        {
            var entityType = typeof(TestAsset);

            _sourceDescriptions
            .GetEntityType(SourceDescriptions.BuildTypeName(entityType))
            .Should().Be(entityType);
        }
示例#2
0
        public void GetComponentName()
        {
            var componentType = typeof(TestComponent1);

            _sourceDescriptions
            .GetComponentName(componentType)
            .Should().Be(SourceDescriptions.BuildTypeName(componentType));
        }
示例#3
0
        protected EntityConverter(IServiceProvider services, bool isCustomType)
        {
            Contract = Typeof <TEntity> .Raw;

            _customTypeName = isCustomType
                ? SourceDescriptions.BuildTypeName(Typeof <TEntity> .Raw)
                : null;

            _properties = SerializationUtils.ActivatePropertyConverters <TEntity>(services);

            _idConverter         = (IdConverter)_properties[nameof(IEntity.Id)];
            _componentsConverter = (ComponentsConverter)_properties[nameof(IEntity.Components)];
        }
示例#4
0
        public ComponentsConverterShould()
        {
            var provider = new DependencyCollection()
                           .AddECS()
                           .BuildProvider();

            var components = new IComponent[] { Fixture.Create <TestComponent1>(), Fixture.Create <TestComponent2>() };

            _asset = new TestAsset(1, components)
            {
                Reference = CreateAsset(2)
            };

            var converters = provider.GetRequired <IConvertersCollection>();

            _converter = provider.Activate <ComponentsConverter>();

            _assetData = (JsonObject)converters.Write(_asset);

            _component1Name = SourceDescriptions.BuildTypeName(typeof(TestComponent1));
            _component2Name = SourceDescriptions.BuildTypeName(typeof(TestComponent2));
        }
示例#5
0
 public void NotReplaceWordsInEntityTypeName(Type type)
 {
     SourceDescriptions
     .BuildTypeName(type)
     .Should().Be(type.Name);
 }
示例#6
0
 public void ReplaceComponentWord()
 {
     SourceDescriptions
     .BuildTypeName(typeof(TestComponent1))
     .Should().Be(nameof(TestComponent1).Cut("Component"));
 }