package com.sirenian.hellbound.domain.glyph;

import jbehave.core.minimock.UsingMiniMock;
import jbehave.core.mock.Constraint;
import jbehave.core.mock.Mock;

import com.sirenian.hellbound.domain.Segments;
import com.sirenian.hellbound.engine.CollisionDetector;

public class JunkBehaviour extends UsingMiniMock {

	public void shouldInitiallyContainNoSegments() {
		Mock glyphListener = mock(GlyphListener.class);
		Junk junk = new Junk();
		
		glyphListener.expects("reportGlyphMovement").with(new Constraint[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)});
		junk.addListener((GlyphListener)glyphListener);
		
		verifyMocks();
	}
	
	public void shouldAbsorbSegmentsFromOtherGlyphsAndKillThem() {
		Mock glyphListener = mock(GlyphListener.class);
        LivingGlyph glyph = new LivingGlyph(GlyphType.O, CollisionDetector.NULL, 4);
        Segments originalSegments = glyph.getSegments();

		Junk junk = new Junk();
		
		glyphListener.expects("reportGlyphMovement").with(new Constraint[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(originalSegments)});

        junk.addListener((GlyphListener)glyphListener);
		junk.absorb(glyph);
        
		ensureThat(glyph.getSegments(), eq(Segments.EMPTY));
        ensureThat(junk.getSegments(), eq(originalSegments));
        
		verifyMocks();
	}
}

@@ -946,34 +946,169 @@
  = new Junk();%0D%0A
-%09%09
+        glyphListener.expects(%22reportGlyphMovement%22).with(new Constraint%5B%5D %7Beq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)%7D);
 %0D%0A%09%09glyphListene

Fix to junk behaviour