public void ShouldGetMappedMethodByMethodInfo() { var mappedComponent = new MappedComponent(0, typeof(TestComponent)); var mappedMethod = mappedComponent.MapMethod(0, typeof(TestComponent).GetMethod("PublicMethod")); var foundMethod = mappedComponent.GetMethod(mappedMethod.MethodInfo); foundMethod.ShouldBe(mappedMethod); }
public void ShouldThrowWhenMappingDuplicateIds() { var mappedComponent = new MappedComponent(0, typeof(TestComponent)); var mappedMethod = mappedComponent.MapMethod(0, typeof(TestComponent).GetMethod("PublicMethod")); Action action = () => mappedComponent.MapMethod(mappedMethod.Id, typeof(TestComponent).GetMethod("PublicMethod")); action.ShouldThrow <ArgumentException>(); }
public void ShouldAutoMapPublicAndInstanceMethods() { var mappedComponent = new MappedComponent(0, typeof(TestComponent)); mappedComponent.AutomapMethods(); mappedComponent.MappedMethods.Any(t => t.MethodInfo == typeof(TestComponent).GetMethod("StaticMethod")).ShouldBeFalse(); mappedComponent.MappedMethods.Any(t => t.MethodInfo == typeof(TestComponent).GetMethod("PublicMethod")).ShouldBeTrue(); mappedComponent.MappedMethods.Any(t => t.MethodInfo == typeof(TestComponent).GetMethod("PrivateMethod")).ShouldBeFalse(); }
public void Remove(MappedComponent obj) { for (int y = obj.Y; y < obj.Bottom; y++) { for (int x = obj.X; x < obj.Right; x++) { Data[y, x] = '0'; } } }
public void ShouldMapMethod() { var mappedComponent = new MappedComponent(0, typeof(TestComponent)); var mappedMethod = mappedComponent.MapMethod(0, typeof(TestComponent).GetMethod("PublicMethod")); mappedComponent.MappedMethods.ShouldContain(mappedMethod); mappedMethod.Id.ShouldBe((byte)0); mappedMethod.MethodInfo.ShouldBe(typeof(TestComponent).GetMethod("PublicMethod")); mappedMethod.MappedComponent.ShouldBe(mappedComponent); }
public void Add(MappedComponent obj) { if (Collides(obj)) { return; } for (int y = obj.Y; y < obj.Bottom; y++) { for (int x = obj.X; x < obj.Right; x++) { Data[y, x] = obj.MapChar; } } }
public bool Collides(MappedComponent obj) { return(Collides(new Point(obj.X, obj.Y), new Point(obj.Width, obj.Height))); }
public bool FitsOnMap(MappedComponent obj) { return(FitsOnMap(new Point(obj.X, obj.Y), new Point(obj.Width, obj.Height))); }