mockapp.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package mockapp
  2. import (
  3. "context"
  4. "sync"
  5. "wartank/pkg/mock/mockkernel"
  6. "wartank/pkg/types"
  7. )
  8. type MockApp struct {
  9. *mockkernel.MockKernel
  10. fnCancel func()
  11. ctx context.Context
  12. bot types.IWarBot
  13. store types.IStore
  14. block *sync.RWMutex
  15. ServWeb_ types.IServWeb
  16. }
  17. func NewMockApp() *MockApp {
  18. ctxBg := context.Background()
  19. ctx, fnCancel := context.WithCancel(ctxBg)
  20. sf := &MockApp{
  21. MockKernel: mockkernel.NewMockKernel(),
  22. ctx: ctx,
  23. fnCancel: fnCancel,
  24. block: &sync.RWMutex{},
  25. }
  26. return sf
  27. }
  28. func (sf *MockApp) Store() types.IStore {
  29. return sf.store
  30. }
  31. func (sf *MockApp) Bot() types.IWarBot {
  32. return sf.bot
  33. }
  34. func (sf *MockApp) Angar() types.IAngar {
  35. return nil
  36. }
  37. func (sf *MockApp) CtxApp() context.Context {
  38. return sf.ctx
  39. }
  40. func (sf *MockApp) GuiWeb() types.IGuiWeb {
  41. return nil
  42. }
  43. func (sf *MockApp) Tank() types.ITank {
  44. return nil
  45. }
  46. func (sf *MockApp) Run() error {
  47. return nil
  48. }
  49. func (sf *MockApp) CancelApp() {
  50. go sf.fnCancel()
  51. }
  52. func (sf *MockApp) Block() *sync.RWMutex {
  53. return sf.block
  54. }
  55. func (sf *MockApp) NetClient() types.IBotNet {
  56. return nil
  57. }
  58. func (sf *MockApp) ServWeb() types.IServWeb {
  59. return sf.ServWeb_
  60. }
  61. func (sf *MockApp) ServBots() types.IServBots {
  62. return nil
  63. }