public void ColorTest() { string alphabet = "a"; Glyph target = new Glyph(alphabet); Color expected = Color.GREEN; // TODO: 初始化为适当的值 Color actual; target.Color = expected; actual = target.Color; Assert.AreEqual(expected, actual); }
public Glyph getGlyph(string alphabet, Color color) { //首先在缓存中查找对象 if (glyphs.ContainsKey(alphabet)) { return (Glyph)glyphs[alphabet]; } //如果缓存未命中则新建对象并加入缓存 Glyph glyph = new Glyph(alphabet); glyph.Color = color; glyphs.Add(alphabet,glyph); return glyph; }
public void add(Position position, Glyph glyph) { if (position.X < 0 || position.X > this.maxRows) { throw new ValidationException("Invalid Row"); } if (position.Y < 0 || position.Y > this.MaxCols) { throw new ValidationException("Invalid Col"); } //todo the Regex needs to be updated if (!new Regex("^[a-zA-Z,. $]").IsMatch(glyph.Alphabet)) { throw new ValidationException("Invalid Alphabet"); } context.Add(position, glyph); }
public void GlyphConstructorTest() { string alphabet = "a"; // TODO: 初始化为适当的值 Glyph target = new Glyph(alphabet); Assert.AreEqual(alphabet,target.Alphabet); }